File: testapi.c

package info (click to toggle)
mmlib 1.4.2-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,716 kB
  • sloc: ansic: 18,071; makefile: 431; sh: 135; python: 63
file content (88 lines) | stat: -rw-r--r-- 1,498 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
   @mindmaze_header@
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif

#include <check.h>
#include <stdlib.h>
#include <stdio.h>

#include "mmlib.h"
#include "mmsysio.h"
#include "api-testcases.h"

#define TEST_LOCK_REFEREE_SERVER_BIN    TOP_BUILDDIR"/src/"LT_OBJDIR"/lock-referee.exe"

static
void flush_stdout(void)
{
	fflush(stdout);
}


static
Suite* api_suite(void)
{
	Suite *s;
	int i;
	TCase* tc[] = {
		create_allocation_tcase(),
		create_time_tcase(),
		create_thread_tcase(),
		create_file_tcase(),
		create_socket_tcase(),
		create_ipc_tcase(),
		create_dir_tcase(),
		create_shm_tcase(),
		create_dlfcn_tcase(),
		create_process_tcase(),
		create_argparse_tcase(),
		create_utils_tcase(),
		create_advanced_file_tcase(),
	};

	s = suite_create("API");

	for (i = 0; i < MM_NELEM(tc); i++) {
		tcase_add_checked_fixture(tc[i], flush_stdout, flush_stdout);
		suite_add_tcase(s, tc[i]);
	}

	return s;
}


int main(void)
{
	Suite* suite;
	SRunner* runner;
	int exitcode = EXIT_SUCCESS;

	mm_chdir(BUILDDIR);

#if defined(_WIN32)
	mm_setenv("MMLIB_LOCKREF_BIN", TEST_LOCK_REFEREE_SERVER_BIN, MM_ENV_OVERWRITE);
	mm_setenv("PATH", TOP_BUILDDIR"/src/"LT_OBJDIR, MM_ENV_PREPEND);
#endif

	suite = api_suite();
	runner = srunner_create(suite);

#ifdef CHECK_SUPPORT_TAP
	srunner_set_tap(runner, "-");
#endif

	srunner_run_all(runner, CK_ENV);

#ifndef CHECK_SUPPORT_TAP
	if (srunner_ntests_failed(runner) != 0)
		exitcode = EXIT_FAILURE;
#endif

	srunner_free(runner);
	return exitcode;
}