/*
* Copyright (C) 2020 Linux Studio Plugins Project
* (C) 2020 Vladimir Sadovnikov
*
* This file is part of lsp-runtime-lib
* Created on: 13 авг. 2019 г.
*
* lsp-runtime-lib is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* lsp-runtime-lib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with lsp-runtime-lib. If not, see .
*/
#include
#include
#include
#include
using namespace lsp;
#define ENV_VAR_NAME "LSP_TEST_ENV_VAR"
UTEST_BEGIN("runtime.ipc", process)
UTEST_TIMELIMIT(10)
void test_envs(ipc::Process &p)
{
size_t envs = p.envs();
UTEST_ASSERT(envs > 0);
LSPString key, value;
for (size_t i=0; iclose() == STATUS_OK);
UTEST_ASSERT(xstderr->close() == STATUS_OK);
// Analyze exit status
int code = 0;
UTEST_ASSERT(p.exit_code(&code) == STATUS_OK);
printf("Waited process has terminated with code=%d\n", int(code));
UTEST_ASSERT(code == 0);
printf("Parent process has exited\n");
}
else
{
printf("Child process started\n");
// Perform argument check
UTEST_ASSERT(argc == 3);
UTEST_ASSERT(strcmp(argv[0], "child") == 0);
UTEST_ASSERT(strcmp(argv[1], "arg1") == 0);
UTEST_ASSERT(strcmp(argv[2], "arg2") == 0);
LSPString value;
UTEST_ASSERT(system::get_env_var(ENV_VAR_NAME, &value) == STATUS_OK);
UTEST_ASSERT(value.equals_ascii("test_value"));
// Perform a sleep for synchronization with caller
printf("Entering sleep\n");
ipc::Thread::sleep(2 * 1000);
printf("Child process has exited\n");
}
}
UTEST_END;