forked from linux-test-project/ltp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor timer_getoverrun test using new LTP API
Link: https://lore.kernel.org/ltp/[email protected]/ Reviewed-by: Richard Palethorpe <[email protected]> Reviewed-by: Cyril Hrubis <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Signed-off-by: Andrea Cervesato <[email protected]>
- Loading branch information
Showing
1 changed file
with
31 additions
and
74 deletions.
There are no files selected for viewing
105 changes: 31 additions & 74 deletions
105
testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,45 @@ | ||
/****************************************************************************** | ||
* Copyright (c) Crackerjack Project., 2007 * | ||
* Porting from Crackerjack to LTP is done by: * | ||
* Manas Kumar Nayak <[email protected]> * | ||
* Copyright (c) 2013 Cyril Hrubis <[email protected]> * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* This program is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See * | ||
* the GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU General Public License * | ||
* along with this program; if not, write to the Free Software Foundation, * | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * | ||
* * | ||
******************************************************************************/ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* | ||
* Copyright (c) International Business Machines Corp., 2001 | ||
* Porting from Crackerjack to LTP is done by: | ||
* Manas Kumar Nayak <[email protected]> | ||
* | ||
* Copyright (c) Linux Test Project, 2009-2023 | ||
* Copyright (c) 2013 Cyril Hrubis <[email protected]> | ||
* Copyright (C) 2023 SUSE LLC Andrea Cervesato <[email protected]> | ||
*/ | ||
|
||
/*\ | ||
* [Description] | ||
* | ||
* This test checks base timer_getoverrun() functionality. | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <errno.h> | ||
#include <time.h> | ||
#include <signal.h> | ||
#include <sys/syscall.h> | ||
|
||
#include "test.h" | ||
#include <time.h> | ||
#include "tst_safe_clocks.h" | ||
#include "lapi/syscalls.h" | ||
|
||
char *TCID = "timer_getoverrun01"; | ||
int TST_TOTAL = 1; | ||
|
||
static void cleanup(void) | ||
static void run(void) | ||
{ | ||
|
||
tst_rmdir(); | ||
} | ||
|
||
static void setup(void) | ||
{ | ||
TEST_PAUSE; | ||
tst_tmpdir(); | ||
} | ||
|
||
int main(int ac, char **av) | ||
{ | ||
int lc; | ||
int timer; | ||
timer_t timer; | ||
struct sigevent ev; | ||
|
||
tst_parse_opts(ac, av, NULL, NULL); | ||
|
||
setup(); | ||
|
||
ev.sigev_value = (union sigval) 0; | ||
ev.sigev_signo = SIGALRM; | ||
ev.sigev_notify = SIGEV_SIGNAL; | ||
TEST(tst_syscall(__NR_timer_create, CLOCK_REALTIME, &ev, &timer)); | ||
|
||
if (TEST_RETURN != 0) | ||
tst_brkm(TBROK | TTERRNO, cleanup, "Failed to create timer"); | ||
ev.sigev_signo = SIGALRM; | ||
|
||
for (lc = 0; TEST_LOOPING(lc); ++lc) { | ||
tst_count = 0; | ||
if (tst_syscall(__NR_timer_create, CLOCK_REALTIME, &ev, &timer)) | ||
tst_brk(TBROK | TERRNO, "timer_create() failed"); | ||
|
||
TEST(tst_syscall(__NR_timer_getoverrun, timer)); | ||
if (TEST_RETURN == 0) { | ||
tst_resm(TPASS, | ||
"timer_getoverrun(CLOCK_REALTIME) Passed"); | ||
} else { | ||
tst_resm(TFAIL | TTERRNO, | ||
"timer_getoverrun(CLOCK_REALTIME) Failed"); | ||
} | ||
TST_EXP_POSITIVE(tst_syscall(__NR_timer_getoverrun, timer)); | ||
|
||
TEST(tst_syscall(__NR_timer_getoverrun, -1)); | ||
if (TEST_RETURN == -1 && TEST_ERRNO == EINVAL) { | ||
tst_resm(TPASS, "timer_gettime(-1) Failed: EINVAL"); | ||
} else { | ||
tst_resm(TFAIL | TTERRNO, | ||
"timer_gettime(-1) = %li", TEST_RETURN); | ||
} | ||
} | ||
if (tst_syscall(__NR_timer_delete, timer)) | ||
tst_brk(TBROK | TERRNO, "timer_delete() failed"); | ||
|
||
cleanup(); | ||
tst_exit(); | ||
TST_EXP_FAIL(tst_syscall(__NR_timer_getoverrun, timer), EINVAL); | ||
} | ||
|
||
static struct tst_test test = { | ||
.test_all = run, | ||
}; |