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