feat(xce-harness-component): consolidate harness_unit_test binary
Relocate the 13 test files that lived inside controller_unit_test into src/harness/testsuite/, add a new Unity runner (harness_test.c, modeled on controller_test.c) carrying their extern/RUN_TEST entries, and register the new harness_unit_test executable + suite in src/harness/meson.build with an explicit build-order dependency on xce_test (two of its tests spawn that binary over a pty). Finish clearing the controller side: remove test_test_cli.c/ test_xcetest_process_entry.c from controller_unit_test_src and their extern/RUN_TEST entries from controller_test.c, and remove the temporary xce_test_controller_link symlink bridge task 1.1 added (no longer needed now that both binaries build as siblings under harness/). Verified: harness suite 132 Tests 0 Failures 0 Ignored; controller suite 1199 Tests 0 Failures 0 Ignored. 1199+132=1331 matches the pre-move controller_unit_test baseline exactly (cross-checked against buglog bug-1798/bug-1805). Task 2.1 of xce-harness-component. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
parent
79628f7b2b
commit
b5873a67aa
18 changed files with 192 additions and 29 deletions
110
src/harness/testsuite/harness_test.c
Normal file
110
src/harness/testsuite/harness_test.c
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
#include <argp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <unity/unity.h>
|
||||
|
||||
extern void test_waldump(void);
|
||||
extern void test_walcompare(void);
|
||||
extern void test_snapverify(void);
|
||||
extern void test_snapdiff(void);
|
||||
extern void test_configcompare(void);
|
||||
extern void test_rcfile(void);
|
||||
extern void test_flagspec(void);
|
||||
extern void test_xcetest_interrupt(void);
|
||||
extern void test_interruptcall(void);
|
||||
extern void test_confirm(void);
|
||||
extern void test_listfmt_json(void);
|
||||
extern void test_xcetest_process_entry(void);
|
||||
extern void test_test_cli(void);
|
||||
|
||||
void setUp(void) { return; }
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
printf("\n-----------------------------------------------------\n");
|
||||
return;
|
||||
}
|
||||
|
||||
static char doc[] = "harness_test";
|
||||
static char args_doc[] = "";
|
||||
|
||||
#define MAX_TESTS (256)
|
||||
|
||||
struct arguments {
|
||||
int ntests;
|
||||
char* tests[MAX_TESTS];
|
||||
};
|
||||
|
||||
static struct argp_option options[] = {
|
||||
{ "run", 't', "STR", 0, "run test" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static error_t parse_opt(int key, char* arg, struct argp_state* state)
|
||||
{
|
||||
struct arguments* arguments = state->input;
|
||||
|
||||
switch (key) {
|
||||
case 't':
|
||||
if (arguments->ntests >= MAX_TESTS) {
|
||||
fprintf(stderr, "Too many tests\n");
|
||||
exit(-1);
|
||||
}
|
||||
arguments->tests[arguments->ntests] = arg;
|
||||
arguments->ntests++;
|
||||
break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct argp argp = { options, parse_opt, args_doc, doc };
|
||||
struct arguments arguments;
|
||||
|
||||
static int check_test(struct arguments* args, char* x)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (args->ntests == 0) {
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < args->ntests; i++) {
|
||||
if (strcmp(x, args->tests[i]) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define TEST(x) \
|
||||
do { \
|
||||
if (check_test(&arguments, #x)) { \
|
||||
x(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||
|
||||
UNITY_BEGIN();
|
||||
TEST(test_waldump);
|
||||
TEST(test_walcompare);
|
||||
TEST(test_snapverify);
|
||||
TEST(test_snapdiff);
|
||||
TEST(test_configcompare);
|
||||
TEST(test_rcfile);
|
||||
TEST(test_flagspec);
|
||||
TEST(test_xcetest_interrupt);
|
||||
TEST(test_interruptcall);
|
||||
TEST(test_confirm);
|
||||
TEST(test_listfmt_json);
|
||||
TEST(test_xcetest_process_entry);
|
||||
TEST(test_test_cli);
|
||||
|
||||
return UNITY_END();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue