File: test.c

package info (click to toggle)
accel-config 4.1.9-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,384 kB
  • sloc: ansic: 19,011; sh: 1,317; makefile: 190
file content (55 lines) | stat: -rw-r--r-- 1,120 bytes parent folder | download | duplicates (3)
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
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright(c) 2019 Intel Corporation. All rights reserved. */

#include <stdio.h>
#include <limits.h>
#include <syslog.h>
#include <test.h>
#include <util/parse-options.h>

static char *result(int rc)
{
	if (rc == EXIT_SKIP)
		return "SKIP";
	else if (rc)
		return "FAIL";
	else
		return "PASS";
}

int cmd_test(int argc, const char **argv, struct accfg_ctx *ctx)
{
	struct accfg_test *test;
	int loglevel = LOG_DEBUG, i, rc;
	const char * const u[] = {
		"accel-config test [<options>]",
		NULL
	};
	const struct option options[] = {
	OPT_INTEGER('l', "loglevel", &loglevel,
		"set the log level (default LOG_DEBUG)"),
	OPT_END(),
	};

	argc = parse_options(argc, argv, options, u, 0);

	for (i = 0; i < argc; i++)
		error("unknown parameter \"%s\"\n", argv[i]);

	if (argc)
		usage_with_options(u, options);
	else
		test = accfg_test_new(0);
	if (!test)
		return EXIT_FAILURE;

	printf("run test_libaccfg\n");
	rc = test_libaccfg(loglevel, test, ctx);
	fprintf(stderr, "test-libaccfg: %s\n", result(rc));
	free(test);
	if (rc)
		return rc;
	printf("SUCCESS!\n");

	return 0;
}