Lolly 1.4.27
Loading...
Searching...
No Matches
subprocess_test.cpp
Go to the documentation of this file.
1
2/******************************************************************************
3 * MODULE : subprocess_test.cpp
4 * DESCRIPTION: tests on subprocess related routines
5 * COPYRIGHT : (C) 2023 Darcy Shen
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11
12#include "a_lolly_test.hpp"
14#include "sys_utils.hpp"
15
18
20
21TEST_CASE ("check_output") {
22 string stdout_result;
23 string stderr_result;
24 if (!os_wasm () && !os_mingw ()) {
25 lolly::system::check_stdout ("xmake --version", stdout_result);
26 CHECK (N (stdout_result) > 0);
27 lolly::system::check_stderr ("ls /no_such_dir", stderr_result);
28 CHECK (N (stderr_result) > 0);
29 }
30}
31
32TEST_CASE ("call") {
33#ifdef OS_WASM
34 CHECK_EQ (call ("xmake --version"), -1);
35 CHECK_EQ (call ("no_such_command"), -1);
36 CHECK_EQ (call (""), -1);
37#else
38#ifndef OS_MINGW
39 CHECK (call ("xmake --version") == 0);
40#endif
41 CHECK (call ("no_such_command") != 0);
42 CHECK (call ("") != 0);
43#endif
44}
45
int N(array< T > a)
Get the length of the array.
Definition array.hpp:170
The list class represents a linked list.
Definition list.hpp:48
#define TEST_MEMORY_LEAK_INIT
#define TEST_MEMORY_LEAK_ALL
int call(string cmd)
int check_stderr(string cmd, string &result)
int check_stdout(string cmd, string &result)
int check_output(string s, string &result, bool stderr_only, int64_t timeout)
TEST_CASE("test for operator+= and advance()")
bool os_mingw()
bool os_wasm()