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