• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
4  */
5 
6 /*
7  * Basic unit test for the tst_strstatus() function.
8  */
9 
10 #include <string.h>
11 #include "tst_test.h"
12 
13 static struct tcase {
14 	int status;
15 	const char *str;
16 } tcases[] = {
17 	{0x0100, "exited with 1"},
18 	{0x0001, "killed by SIGHUP"},
19 	{0x137f, "is stopped"},
20 	{0xffff, "is resumed"},
21 	{0xff, "invalid status 0xff"},
22 };
23 
do_test(unsigned int n)24 static void do_test(unsigned int n)
25 {
26 	const char *str_status = tst_strstatus(tcases[n].status);
27 
28 	if (strcmp(str_status, tcases[n].str))
29 		tst_res(TFAIL, "%s != %s", str_status, tcases[n].str);
30 	else
31 		tst_res(TPASS, "%s", str_status);
32 }
33 
34 static struct tst_test test = {
35 	.test = do_test,
36 	.tcnt = ARRAY_SIZE(tcases),
37 };
38