1 /***********************************************************************************************************************************
2 Test Local Command
3 ***********************************************************************************************************************************/
4 #include "common/io/fdRead.h"
5 #include "common/io/fdWrite.h"
6 #include "protocol/client.h"
7 #include "protocol/server.h"
8 
9 #include "common/harnessConfig.h"
10 #include "common/harnessFork.h"
11 
12 /***********************************************************************************************************************************
13 Test Run
14 ***********************************************************************************************************************************/
15 void
testRun(void)16 testRun(void)
17 {
18     FUNCTION_HARNESS_VOID();
19 
20     // *****************************************************************************************************************************
21     if (testBegin("cmdLocal()"))
22     {
23         HRN_FORK_BEGIN()
24         {
25             HRN_FORK_CHILD_BEGIN()
26             {
27                 StringList *argList = strLstNew();
28                 hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
29                 hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
30                 hrnCfgArgRawZ(argList, cfgOptProcess, "1");
31                 hrnCfgArgRawStrId(argList, cfgOptRemoteType, protocolStorageTypeRepo);
32                 HRN_CFG_LOAD(cfgCmdArchiveGet, argList, .role = cfgCmdRoleLocal);
33 
34                 cmdLocal(
35                     protocolServerNew(
36                         PROTOCOL_SERVICE_LOCAL_STR, PROTOCOL_SERVICE_LOCAL_STR, HRN_FORK_CHILD_READ(), HRN_FORK_CHILD_WRITE()));
37             }
38             HRN_FORK_CHILD_END();
39 
40             HRN_FORK_PARENT_BEGIN()
41             {
42                 ProtocolClient *client = protocolClientNew(
43                     STRDEF("test"), PROTOCOL_SERVICE_LOCAL_STR, HRN_FORK_PARENT_READ(0), HRN_FORK_PARENT_WRITE(0));
44                 protocolClientNoOp(client);
45                 protocolClientFree(client);
46             }
47             HRN_FORK_PARENT_END();
48         }
49         HRN_FORK_END();
50     }
51 
52     FUNCTION_HARNESS_RETURN_VOID();
53 }
54