ScriptConnectToDDServer.cpp
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
#include <unistd.h>
#include <errno.h>
#include "CSlim/SlimUtil.h"
#include "CSlim/SlimList.h"
#include "CSlim/Fixtures.h"
#include "CSlimTools.hh"
struct ConnectToDDServer {
ConnectToDDServer() : _buildType("Debug"), _execPath("../build/Debug/bin/"), _workingDirectory("app-debug") {
const char* lBuildType = getenv("BUILD_TYPE");
if ( lBuildType && (strcmp(lBuildType,"Release")==0)) {
_buildType=lBuildType;
_execPath="../build/Release/bin/";
_workingDirectory="app-release";
}
chdir(_workingDirectory.c_str());
}
static ConnectToDDServer* From(void *fixtureStorage) {
return reinterpret_cast<ConnectToDDServer*>(fixtureStorage);
}
std::string _buildType;
std::string _execPath;
std::string _workingDirectory;
};
extern "C" {
void* ConnectToDDServer_Create(StatementExecutor* /*errorHandler*/, SlimList* /*args*/) {
setenv("DDPATH", ".", 1);
return new ConnectToDDServer;
}
void ConnectToDDServer_Destroy(void *fixture) {
delete ConnectToDDServer::From(fixture);
}
static char* login(void */*fixture*/, SlimList */*args*/) {
int ret = system("../script/loginDD_Server.sh");
return CSlimTools::traitReturnSystem(ret);
}
SLIM_CREATE_FIXTURE(ConnectToDDServer)
SLIM_FUNCTION(login)
SLIM_END
}