From: <ro...@us...> - 2002-12-31 22:53:28
|
Update of /cvsroot/ltp/ltp/testcases/kernel/syscalls/syscall In directory sc8-pr-cvs1:/tmp/cvs-serv18276/testcases/kernel/syscalls/syscall Added Files: Makefile syscall01.c Log Message: Added syscall() test ported by Ananda Venkataraman <av...@us...> --- NEW FILE: Makefile --- # # Copyright (c) International Business Machines Corp., 2001 # # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # ########################################################################### # name of file : Makefile # ########################################################################### CFLAGS+= -I../../../../include -O -g -Wall LOADLIBES+= -L../../../../lib -lltp SRCS=$(wildcard *.c) TARGETS=$(patsubst %.c,%,$(SRCS)) all: $(TARGETS) install: @for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done clean: rm -f $(TARGETS) --- NEW FILE: syscall01.c --- /* * * Copyright (c) International Business Machines Corp., 2002 * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* 01/02/2003 Port to LTP av...@us...*/ /* 06/30/2001 Port to Linux nsh...@us... */ /* * NAME * syscall1.c -- test syscall * * CALLS * syscall * * ALGORITHM * Use syscall to simulate some section 2 calls and make sure * things work as expected. Pretty simple, but if it works * for a few it should work for all. * * RESTRICTIONS * The syscall numbers are system dependent!! They represent * entries in a table and can be changed from kernel to kernel. * They ARE differnet between vax 4.2BSD and our ported system. */ #include <stdio.h> /* needed by testhead.h */ #include <syscall.h> #include <errno.h> /***** LTP Port *****/ #include "test.h" #include "usctest.h" #define FAILED 0 #define PASSED 1 char *TCID = "syscall01"; int local_flag = PASSED; int block_number; int errno; FILE *temp; int TST_TOTAL = 1; extern int Tst_count; /***** ** ** *****/ //char progname[]= "syscall1()"; #define ITER 500 int t_flag; int errno; /***** LTP Port *****/ void setup(); int blenter(); int blexit(); int anyfail(); void cleanup(); void do_setpg(); void fail_exit(); /***** ** ** *****/ /*--------------------------------------------------------------*/ int main (int argc, char *argv[]) { register int i; int v1, v2; setup(); /* temp file is now open */ /*--------------------------------------------------------------*/ blenter(); for (i=0; i < ITER; i++) { v1 = getpid(); v2 = syscall(SYS_getpid); if (v1 != v2) { fprintf(temp, "\tgetpid syscall failed.\n"); fprintf(temp, "\t iteration %d\n", i); local_flag = FAILED; break; } } blexit(); /*--------------------------------------------------------------*/ blenter(); for (i=0; i < ITER; i++) { v1 = getuid(); v2 = syscall(SYS_getuid); if (v1 != v2) { fprintf(temp, "\tgetuid syscall failed.\n"); fprintf(temp, "\t iteration %d\n", i); local_flag = FAILED; break; } } blexit(); /*--------------------------------------------------------------*/ blenter(); for (i=0; i < ITER; i++) { v1 = getgid(); v2 = syscall(SYS_getgid); if (v1 != v2) { fprintf(temp, "\tgetgid syscall failed.\n"); fprintf(temp, "\t iteration %d\n", i); local_flag = FAILED; break; } } blexit(); /*--------------------------------------------------------------*/ /*************************************************************** * cleanup and exit ***************************************************************/ cleanup(); anyfail(); /* THIS CALL DOES NOT RETURN - EXITS!! */ return(0); } /*--------------------------------------------------------------*/ /***** LTP Port *****/ /* functions */ void cleanup() { /* * print timing stats if that option was specified. * print errno log if that option was specified. */ TEST_CLEANUP; /* exit with return code appropriate for results */ tst_exit(); } /* End cleanup() */ void setup() { temp = stderr; } int blenter() { local_flag = PASSED; return(0); } int blexit() { (local_flag == PASSED) ? tst_resm(TPASS, "Test passed\n") : tst_resm(TFAIL, "Test failed\n"); return(0); } int anyfail() { tst_exit(); return(0); } void fail_exit() { local_flag = FAILED; blexit(); anyfail(); } /***** ** ** *****/ |