Importing Egor's testsuite.
This commit is contained in:
27
winsup/testsuite/ChangeLog
Normal file
27
winsup/testsuite/ChangeLog
Normal file
@ -0,0 +1,27 @@
|
||||
2000-09-02 Egor Duda <deo@logos-m.ru>
|
||||
|
||||
* moved here everything from cygwin/testsuite/
|
||||
* configure.in: New file
|
||||
* configure: New file, generated from configure.in
|
||||
with autoconf 2.13
|
||||
* Makefile.in: New file
|
||||
* libltp/: New directory. Contains a support library
|
||||
and headers for tests in winsup.api/ltp/
|
||||
* config/default.exp: Print value of CYGWIN environment
|
||||
variable when test completed
|
||||
* winsup.api/samples/xf-sample-fail.c renamed to
|
||||
winsup.api/samples/sample-fail.c
|
||||
* winsup.api/samples/xf-sample-miscompile.c renamed to
|
||||
winsup.api/samples/sample-miscompile.c
|
||||
* winsup.api/known_bugs.tcl: New file.
|
||||
* winsup.api/winsup.exp: Xfail test if its name is in
|
||||
list from known_bugs.tcl
|
||||
* winsup.api/winsup.exp: Don't stop if compiled test executable
|
||||
can't be deleted
|
||||
* winsup.api/winsup.exp: If in verbose mode, write test output
|
||||
to <testname>.log
|
||||
* winsup.api/ltp/: New directory. Contains cygwin port of testsuite
|
||||
from Linux Testing Project
|
||||
* winsup.api/sigchld.c: New file. Test if process recieves SIGCHLD
|
||||
signal when its child terminates.
|
||||
* winsup.api/waitpid.c: New file. Test if waitpid function works
|
||||
182
winsup/testsuite/Makefile.in
Normal file
182
winsup/testsuite/Makefile.in
Normal file
@ -0,0 +1,182 @@
|
||||
# Makefile.in for Cygwin's testsuite.
|
||||
# Copyright 2000 Red Hat, Inc.
|
||||
#
|
||||
# This file is part of Cygwin.
|
||||
#
|
||||
# This software is a copyrighted work licensed under the terms of the
|
||||
# Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||
# details.
|
||||
|
||||
# This makefile requires GNU make.
|
||||
|
||||
SHELL:=@SHELL@
|
||||
srcdir:=@srcdir@
|
||||
objdir:=.
|
||||
libltp_srcdir=$(srcdir)/libltp
|
||||
|
||||
VPATH:=$(srcdir):$(libltp_srcdir)/lib
|
||||
|
||||
target_alias:=@target_alias@
|
||||
build_alias:=@build_alias@
|
||||
host_alias:=@host_alias@
|
||||
prefix:=@prefix@
|
||||
|
||||
program_transform_name:=@program_transform_name@
|
||||
exec_prefix:=@exec_prefix@
|
||||
bindir:=@bindir@
|
||||
libdir:=@libdir@
|
||||
ifeq ($(target_alias),$(host_alias))
|
||||
ifeq ($(build_alias),$(host_alias))
|
||||
tooldir:=$(exec_prefix)
|
||||
else
|
||||
tooldir:=$(exec_prefix)/$(target_alias)
|
||||
endif
|
||||
else
|
||||
tooldir:=$(exec_prefix)/$(target_alias)
|
||||
endif
|
||||
datadir:=@datadir@
|
||||
infodir:=@infodir@
|
||||
includedir:=@includedir@
|
||||
|
||||
TESTSUP_INCLUDES:=-I$(libltp_srcdir)/include
|
||||
|
||||
INSTALL:=@INSTALL@
|
||||
INSTALL_PROGRAM:=@INSTALL_PROGRAM@
|
||||
|
||||
#
|
||||
# --enable options from configure
|
||||
#
|
||||
|
||||
CC:=@CC@
|
||||
# FIXME: Which is it, CC or CC_FOR_TARGET?
|
||||
CC_FOR_TARGET:=$(CC)
|
||||
CFLAGS:=@CFLAGS@ -MD -Wno-write-strings $(TESTSUP_INCLUDES)
|
||||
CXXFLAGS:=@CXXFLAGS@
|
||||
|
||||
AR:=@AR@
|
||||
AR_FLAGS:=qv
|
||||
RANLIB:=@RANLIB@
|
||||
LD:=@LD@
|
||||
DLLTOOL:=@DLLTOOL@
|
||||
WINDRES:=@WINDRES@
|
||||
AS:=@AS@
|
||||
|
||||
#
|
||||
# Include common definitions for winsup directory
|
||||
#
|
||||
include $(srcdir)/../Makefile.common
|
||||
|
||||
INSTALL_DATA:=$(SHELL) $(updir1)/install-sh -c
|
||||
|
||||
# Setup the testing framework, if you have one
|
||||
EXPECT = `if [ -f $${rootme}/../../expect/expect$(EXEEXT) ] ; then \
|
||||
echo $${rootme}/../../expect/expect$(EXEEXT) ; \
|
||||
else echo expect ; fi`
|
||||
|
||||
RUNTEST = `if [ -f $${srcdir}/../dejagnu/runtest ] ; then \
|
||||
echo $${srcdir}/../dejagnu/runtest ; \
|
||||
else echo runtest; fi`
|
||||
RUNTESTFLAGS =
|
||||
|
||||
ifdef VERBOSE
|
||||
RUNTESTFLAGS = -v
|
||||
endif
|
||||
|
||||
RUNTIME=$(cygwin_build)/new-cygwin1.dll $(cygwin_build)/new-libcygwin.a $(cygwin_build)/cygrun.exe
|
||||
|
||||
TESTSUP_LIB_NAME:=libltp.a
|
||||
TESTSUP_OFILES:=${sort ${addsuffix .o,${basename ${notdir ${wildcard $(libltp_srcdir)/lib/*.c}}}}}
|
||||
|
||||
.PHONY: all force dll_ofiles install all_target install_target all_host install_host
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .cc .def .a .o .d
|
||||
|
||||
all_host=@all_host@
|
||||
install_host=@install_host@
|
||||
|
||||
all: $(TESTSUP_LIB_NAME)
|
||||
|
||||
force:
|
||||
|
||||
install:
|
||||
|
||||
install_host:
|
||||
|
||||
clean:
|
||||
-rm -f *.o *.dll *.a *.exp junk *.bak *.base *.exe testsuite/*
|
||||
|
||||
maintainer-clean realclean: clean
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-rm -fr configure
|
||||
|
||||
# Rule to build libltp.a
|
||||
|
||||
$(TESTSUP_LIB_NAME): $(TESTSUP_OFILES)
|
||||
$(AR) rcv temp.a $(TESTSUP_OFILES)
|
||||
mv temp.a $(TESTSUP_LIB_NAME)
|
||||
|
||||
$(RUNTIME) : $(cygwin_build)/Makefile
|
||||
@$(MAKE) --no-print-dir -C $(@D) $(@F)
|
||||
|
||||
# Rule to make stub library used by "make check"
|
||||
|
||||
#
|
||||
|
||||
# These targets are for the dejagnu testsuites. The file site.exp
|
||||
# contains global variables that all the testsuites will use.
|
||||
|
||||
# Set to $(target_alias)/ for cross.
|
||||
target_subdir = @target_subdir@
|
||||
|
||||
site.exp: ./config.status Makefile
|
||||
@echo "Making a new config file..."
|
||||
-@rm -f ./tmp?
|
||||
@touch site.exp
|
||||
-@mv site.exp site.bak
|
||||
@echo "## these variables are automatically generated by make ##" > ./tmp0
|
||||
@echo "# Do not edit here. If you wish to override these values" >> ./tmp0
|
||||
@echo "# add them to the last section" >> ./tmp0
|
||||
@echo "set rootme \"`pwd`\"" >> ./tmp0
|
||||
@echo "set runtime_root \"\$$rootme/../cygwin\"" >> ./tmp0
|
||||
@echo "set srcdir \"`cd ${srcdir}; pwd`\"" >> ./tmp0
|
||||
@echo "set host_triplet $(host_canonical)" >> ./tmp0
|
||||
@echo "set build_triplet $(build_canonical)" >> ./tmp0
|
||||
@echo "set target_triplet $(target)" >> ./tmp0
|
||||
@echo "set target_alias $(target_alias)" >> ./tmp0
|
||||
@echo "set CC \"$(CC)\"" >> ./tmp0
|
||||
# CFLAGS is set even though it's empty to show we reserve the right to set it.
|
||||
@echo "set CFLAGS \"\"" >> ./tmp0
|
||||
echo "set tmpdir $(objdir)/testsuite" >> ./tmp0
|
||||
@echo "set ltp_includes \"$(libltp_srcdir)/include\"" >> ./tmp0
|
||||
@echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
|
||||
@cat ./tmp0 > site.exp
|
||||
@cat site.bak | sed \
|
||||
-e '1,/^## All variables above are.*##/ d' >> site.exp
|
||||
-@rm -f ./tmp?
|
||||
|
||||
testsuite/site.exp: site.exp
|
||||
if [ -d testsuite ]; then \
|
||||
true; \
|
||||
else \
|
||||
mkdir testsuite; \
|
||||
fi
|
||||
rm -rf testsuite/site.exp
|
||||
cp site.exp testsuite/site.exp
|
||||
|
||||
# Note: we set the PATH so that we can pick up new-cygwin1.dll
|
||||
|
||||
check: $(TESTSUP_LIB_NAME) $(RUNTIME) testsuite/site.exp
|
||||
-rootme=`pwd`; export rootme; \
|
||||
srcdir=`cd ${srcdir}; pwd` ; export srcdir ; \
|
||||
cd testsuite; \
|
||||
EXPECT=${EXPECT} ; export EXPECT ; \
|
||||
if [ -f $${rootme}/../expect/expect ] ; then \
|
||||
TCL_LIBRARY=`cd .. ; cd ${srcdir}/../tcl/library ; pwd` ; \
|
||||
export TCL_LIBRARY ; fi ; \
|
||||
PATH=$${rootme}/../cygwin:$${PATH} ;\
|
||||
$(RUNTEST) --tool winsup $(RUNTESTFLAGS)
|
||||
|
||||
#
|
||||
|
||||
@ -1,5 +1,13 @@
|
||||
proc winsup_version {} {
|
||||
clone_output "\n[exec grep ^%%% ../new-cygwin1.dll]\n"
|
||||
global env
|
||||
global rootme
|
||||
puts stderr "root=$rootme"
|
||||
clone_output "\n[exec grep ^%%% $rootme/../cygwin/new-cygwin1.dll]\n"
|
||||
if { [info exists env(CYGWIN)] } {
|
||||
clone_output "CYGWIN=$env(CYGWIN)\n"
|
||||
} else {
|
||||
clone_output "CYGWIN=\n"
|
||||
}
|
||||
}
|
||||
|
||||
proc winsup_exit {} {
|
||||
|
||||
1193
winsup/testsuite/configure
vendored
Normal file
1193
winsup/testsuite/configure
vendored
Normal file
File diff suppressed because it is too large
Load Diff
19
winsup/testsuite/configure.in
Executable file
19
winsup/testsuite/configure.in
Executable file
@ -0,0 +1,19 @@
|
||||
dnl Autoconf configure script for Cygwin's testsuite.
|
||||
dnl Copyright 2000 Red Hat, Inc.
|
||||
dnl
|
||||
dnl This file is part of Cygwin.
|
||||
dnl
|
||||
dnl This software is a copyrighted work licensed under the terms of the
|
||||
dnl Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||
dnl details.
|
||||
dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.12)
|
||||
AC_INIT(Makefile.in)
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_CHECK_TOOL(AR,ar)
|
||||
|
||||
AC_OUTPUT(Makefile)
|
||||
8
winsup/testsuite/winsup.api/known_bugs.tcl
Normal file
8
winsup/testsuite/winsup.api/known_bugs.tcl
Normal file
@ -0,0 +1,8 @@
|
||||
set xfail_list [list dup03 dup05 \
|
||||
fcntl05 fcntl07B fcntl09 fcntl10 \
|
||||
fsync01 gethostid01 lseek04 mknod01 \
|
||||
setgroups01 setregid01 setreuid01 setuid02 \
|
||||
ulimit01 unlink06 \
|
||||
sample-fail sample-miscompile]
|
||||
|
||||
|
||||
302
winsup/testsuite/winsup.api/ltp/access01.c
Normal file
302
winsup/testsuite/winsup.api/ltp/access01.c
Normal file
@ -0,0 +1,302 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : access01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for access(2) using F_OK,
|
||||
* R_OK, W_OK and X_OK arguments.
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 6
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) access(2) returns 0 for F_OK...(See Description)
|
||||
* 2.) access(2) returns 0 for R_OK...(See Description)
|
||||
* 3.) access(2) returns 0 for W_OK...(See Description)
|
||||
* 4.) access(2) returns 0 for X_OK...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* The libcuts.a and libsys.a libraries must be included in
|
||||
* the compilation of this test.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the access(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* access(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
* Create a temp directory and cd to it.
|
||||
* Creat a temp file wil read, write and execute permissions.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call with F_OK on tmp file
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
* Execute system call with X_OK on tmp file...
|
||||
* Execute system call with W_OK on tmp file...
|
||||
* Execute system call with R_OK on tmp file...
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
char *TCID="access01"; /* Test program identifier. */
|
||||
int TST_TOTAL=4; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
|
||||
char Fname[255];
|
||||
|
||||
static struct test_case_t {
|
||||
char *file;
|
||||
int mode;
|
||||
char *string;
|
||||
int experrno;
|
||||
} Test_cases[] = {
|
||||
{ Fname, F_OK, "F_OK", 0 },
|
||||
{ Fname, X_OK, "X_OK", 0 },
|
||||
{ Fname, W_OK, "W_OK", 0 },
|
||||
{ Fname, R_OK, "R_OK", 0 },
|
||||
};
|
||||
|
||||
int Ntc = sizeof(Test_cases) / sizeof(struct test_case_t);
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
int tc;
|
||||
|
||||
TST_TOTAL=Ntc;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for (tc=0; tc<Ntc; tc++) {
|
||||
/*
|
||||
* Call access(2)
|
||||
*/
|
||||
TEST(access(Test_cases[tc].file, Test_cases[tc].mode));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 && Test_cases[tc].experrno == 0 ) {
|
||||
tst_resm(TFAIL, "access(%s, %s) Failed, errno=%d : %s",
|
||||
Test_cases[tc].file, Test_cases[tc].string,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
|
||||
} else if ( TEST_RETURN != -1 && Test_cases[tc].experrno != 0 ) {
|
||||
tst_resm(TFAIL, "access(%s, %s) returned %d, exp -1, errno:%d",
|
||||
Test_cases[tc].file, Test_cases[tc].string,
|
||||
TEST_RETURN, Test_cases[tc].experrno);
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "access(%s, %s) returned %d",
|
||||
Test_cases[tc].file, Test_cases[tc].string,
|
||||
TEST_RETURN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
int fd;
|
||||
struct stat stbuf;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
umask(0); /* reset umask avoid it affects on modes */
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/*
|
||||
* Since files inherit group ids, make sure our dir has a valid grp
|
||||
* to us.
|
||||
*/
|
||||
chown(".", -1, getgid());
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(Fname,"accessfile");
|
||||
|
||||
if ((fd = open(Fname, O_RDWR|O_CREAT, 06777)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "open(%s, O_RDWR|O_CREAT,06777) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
else if (close(fd) == -1) {
|
||||
tst_resm(TINFO, "close(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/*
|
||||
* force the mode to be set to 6777
|
||||
*/
|
||||
if (chmod(Fname, 06777) == -1 ) {
|
||||
tst_brkm(TBROK, cleanup, "chmod(%s, 06777) failed, errno:%d %s\n",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
stat(Fname, &stbuf);
|
||||
|
||||
if ( (stbuf.st_mode & 06777) != 06777 ) {
|
||||
/*
|
||||
* file can not be properly setup
|
||||
*/
|
||||
}
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove the temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
507
winsup/testsuite/winsup.api/ltp/access03.c
Normal file
507
winsup/testsuite/winsup.api/ltp/access03.c
Normal file
@ -0,0 +1,507 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : access03
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : EFAULT error testing for access(2)
|
||||
*
|
||||
* PARENT DOCUMENT : acstds01
|
||||
*
|
||||
* TEST CASE TOTAL : 8
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Kathy Olmsted
|
||||
*
|
||||
* CO-PILOT : Tom Hampson
|
||||
*
|
||||
* DATE STARTED : 05/13/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* access(2) test for errno(s) EFAULT.
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Make and change to a temporary directory.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno.
|
||||
* If doing functional test
|
||||
* check the errno returned and print result message
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
* Remove the temporary directory and exit.
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
#include <unistd.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
char *get_high_address();
|
||||
|
||||
char *TCID="access03"; /* Test program identifier. */
|
||||
int TST_TOTAL=8; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={EFAULT, 0}; /* List must end with 0 */
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos. */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* R_OK on low pointer (-1) for path
|
||||
*/
|
||||
|
||||
|
||||
/* Call access(2) */
|
||||
TEST(access( (char *)-1,R_OK));
|
||||
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if (TEST_ERRNO == EFAULT) {
|
||||
tst_resm(TPASS,
|
||||
"access((char *)-1,R_OK) failed as expected with errno %d (EFAULT) : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char *)-1,R_OK) failed with errno %d : %s but expected %d (EFAULT)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO),EFAULT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char *)-1,R_OK) succeeded unexpectedly.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* W_OK on low pointer (-1) for path
|
||||
*/
|
||||
|
||||
|
||||
/* Call access(2) */
|
||||
TEST(access( (char *)-1,W_OK));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if (TEST_ERRNO == EFAULT) {
|
||||
tst_resm(TPASS,
|
||||
"access((char *)-1,W_OK) failed as expected with errno %d (EFAULT) : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char *)-1,W_OK) failed with errno %d : %s but expected %d (EFAULT)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO),EFAULT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char *)-1,W_OK) succeeded unexpectedly.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* X_OK on low pointer (-1) for path
|
||||
*/
|
||||
|
||||
|
||||
/* Call access(2) */
|
||||
TEST(access( (char *)-1,X_OK));
|
||||
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if (TEST_ERRNO == EFAULT) {
|
||||
tst_resm(TPASS,
|
||||
"access((char*)-1,X_OK) failed as expected with errno %d (EFAULT) : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char*)-1,X_OK) failed with errno %d : %s but expected %d (EFAULT)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO),EFAULT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char*)-1,X_OK) succeeded unexpectedly.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* F_OK on low pointer (-1) for path
|
||||
*/
|
||||
|
||||
|
||||
/* Call access(2) */
|
||||
TEST(access( (char *)-1,F_OK));
|
||||
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if (TEST_ERRNO == EFAULT) {
|
||||
tst_resm(TPASS,
|
||||
"access((char*)-1,F_OK) failed as expected with errno %d (EFAULT) : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char*)-1,F_OK) failed with errno %d : %s but expected %d (EFAULT)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO),EFAULT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char*)-1,F_OK) succeeded unexpectedly.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* R_OK on high pointer (sbrk(0)+1) for path
|
||||
*/
|
||||
|
||||
|
||||
/* Call access(2) */
|
||||
TEST(access(get_high_address(),R_OK));
|
||||
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if (TEST_ERRNO == EFAULT) {
|
||||
tst_resm(TPASS,
|
||||
"access((char*)sbrk(0)+1,R_OK) failed as expected with errno %d (EFAULT) : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char*)sbrk(0)+1,R_OK) failed with errno %d : %s but expected %d (EFAULT)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO),EFAULT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char*)sbrk(0)+1,R_OK) succeeded unexpectedly.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* W_OK on high pointer (sbrk(0)+1) for path
|
||||
*/
|
||||
|
||||
|
||||
/* Call access(2) */
|
||||
TEST(access(get_high_address(),W_OK));
|
||||
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if (TEST_ERRNO == EFAULT) {
|
||||
tst_resm(TPASS,
|
||||
"access((char*)sbrk(0)+1,W_OK) failed as expected with errno %d (EFAULT) : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char*)sbrk(0)+1,W_OK) failed with errno %d : %s but expected %d (EFAULT)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO),EFAULT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char*)sbrk(0)+1,W_OK) succeeded unexpectedly.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* X_OK on high pointer (sbrk(0)+1) for path
|
||||
*/
|
||||
|
||||
|
||||
/* Call access(2) */
|
||||
TEST(access(get_high_address(),X_OK));
|
||||
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if (TEST_ERRNO == EFAULT) {
|
||||
tst_resm(TPASS,
|
||||
"access(high_address,X_OK) failed as expected with errno %d (EFAULT) : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access(high_address,X_OK) failed with errno %d : %s but expected %d (EFAULT)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO),EFAULT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access(high_address,X_OK) succeeded unexpectedly.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* F_OK on high pointer (sbrk(0)+1) for path
|
||||
*/
|
||||
|
||||
|
||||
/* Call access(2) */
|
||||
TEST(access(get_high_address(),F_OK));
|
||||
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if (TEST_ERRNO == EFAULT) {
|
||||
tst_resm(TPASS,
|
||||
"access((char*)sbrk(0)+1,F_OK) failed as expected with errno %d (EFAULT) : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char*)sbrk(0)+1,F_OK) failed with errno %d : %s but expected %d (EFAULT)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO),EFAULT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"access((char*)sbrk(0)+1,F_OK) succeeded unexpectedly.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make and change to a temporary directory */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove the temporary directory and exit with
|
||||
return code appropriate for results */
|
||||
tst_rmdir();
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
226
winsup/testsuite/winsup.api/ltp/alarm01.c
Normal file
226
winsup/testsuite/winsup.api/ltp/alarm01.c
Normal file
@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : alarm01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for alarm(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) alarm(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* The libcuts.a and libsys.a libraries must be included in
|
||||
* the compilation of this test.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the alarm(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* alarm(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="alarm01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call alarm(2)
|
||||
*/
|
||||
TEST(alarm(1));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
tst_resm(TFAIL, "alarm(1) Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "alarm(1) returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
void trapper();
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
signal(SIGALRM, trapper);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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
|
||||
trapper(sig)
|
||||
int sig;
|
||||
{
|
||||
signal(SIGALRM, trapper);
|
||||
}
|
||||
|
||||
240
winsup/testsuite/winsup.api/ltp/alarm02.c
Normal file
240
winsup/testsuite/winsup.api/ltp/alarm02.c
Normal file
@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : alarm02
|
||||
*
|
||||
* TEST TITLE : Boundary Value Test for alarm(2)
|
||||
*
|
||||
* PARENT DOCUMENT : almtds02
|
||||
*
|
||||
* TEST CASE TOTAL : 3
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* BINARY LOCATION : CUTS_BIN/rf_tests/sys
|
||||
*
|
||||
* SOURCE LOCATION : CUTS_SRC/src/tests/sys
|
||||
*
|
||||
* AUTHOR : Billy Jean Horne
|
||||
*
|
||||
* CO-PILOT : Kathy Olmsted
|
||||
*
|
||||
* DATE STARTED : 06/01/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
* Test Case One - A call to alarm() shall not return an error if
|
||||
* seconds is a -1.
|
||||
* Test FAILS if a non-zero value is returned.
|
||||
* Test Case Two - A call to alarm() shall not return an error if
|
||||
* seconds is the maximum unsigned integer (2**63).
|
||||
* Test FAILS if a non-zero value is returned.
|
||||
* Test Case Three - A call to alarm() shall not return an error if
|
||||
* seconds is the maximum unsigned integer plus 1 ((2**63)+1).
|
||||
* Test FAILS if a non-zero value is returned.
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* The libcuts.a and libsys.a libraries must be included in
|
||||
* the compilation of this test.
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
*
|
||||
* Setup:
|
||||
* Define a cleanup function.
|
||||
*
|
||||
* Test:
|
||||
* Loop for each test case.
|
||||
* Execute alarm (0) system call to clear previous alarm.
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Issue a BROK message and exit the test.
|
||||
* Call alarm() with boundary values for seconds.
|
||||
* Verify that returned value is as expected.
|
||||
* Report results.
|
||||
*
|
||||
* Cleanup:
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <sys/signal.h>
|
||||
#include <limits.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h" /* required for usctest */
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
void alarm_received();
|
||||
|
||||
|
||||
|
||||
char *TCID="alarm02"; /* Test program identifier. */
|
||||
int TST_TOTAL=3; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_ * routines */
|
||||
|
||||
int received_alarm = 0; /* Indicates a SIGALRM was received */
|
||||
|
||||
/************************************************************
|
||||
* Main program
|
||||
***********************************************************/
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
|
||||
/* Parameters for usc code */
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/* Parameters for alarm test */
|
||||
char *buf[] = { "-1", "ULONG_MAX", "ULONG_MAX+1"};
|
||||
unsigned long int sec[] = {-1, ULONG_MAX, ULONG_MAX+1};
|
||||
int exp[] = {0,0,0};
|
||||
int i;
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
|
||||
Tst_count=0;
|
||||
|
||||
for (i=0;i<TST_TOTAL;i++) {
|
||||
|
||||
/* capture an SIGALRM signal */
|
||||
received_alarm = 0;
|
||||
signal(SIGALRM, alarm_received);
|
||||
|
||||
TEST (alarm (sec[i]));
|
||||
/* reset the alarm */
|
||||
alarm (0);
|
||||
if (TEST_RETURN != 0) {
|
||||
tst_resm(TFAIL,
|
||||
"alarm(%u) returned %u, when %u was expected for value %s.",
|
||||
sec[i], TEST_RETURN, exp[i], buf[i]);
|
||||
|
||||
}
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
else if (STD_FUNCTIONAL_TEST) {
|
||||
if (received_alarm == 1) {
|
||||
tst_resm (TFAIL,
|
||||
"alarm(%u) returned %u but an alarm signal was received for value %s.",
|
||||
sec[i], TEST_RETURN, buf[i]);
|
||||
} else {
|
||||
tst_resm (TPASS,
|
||||
"alarm(%u) returned %u as expected for value %s.",
|
||||
sec[i], TEST_RETURN, buf[i]);
|
||||
}
|
||||
|
||||
} /* End of STD_FUNCTIONAL_TEST */
|
||||
} /* End of for loop */
|
||||
/*
|
||||
* Reset alarm before cleanup.
|
||||
*/
|
||||
|
||||
alarm(0);
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
|
||||
void
|
||||
setup()
|
||||
{
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
/* End setup() */
|
||||
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* Cleanup:
|
||||
* exit using tst_exit.
|
||||
***********************************************************/
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void alarm_received()
|
||||
{
|
||||
received_alarm = 1;
|
||||
}
|
||||
|
||||
|
||||
229
winsup/testsuite/winsup.api/ltp/alarm03.c
Normal file
229
winsup/testsuite/winsup.api/ltp/alarm03.c
Normal file
@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : alarm03
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : alarm(2) cleared by a fork
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : Dennis Arason
|
||||
*
|
||||
* DATE STARTED : 08/96
|
||||
*
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) alarm(100), fork, child's alarm(0) shall return 0;
|
||||
* 2.) alarm(100), fork, parent's alarm(0) shall return non-zero.
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the alarm(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* alarm(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
char *TCID="alarm03"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call alarm(2)
|
||||
*/
|
||||
TEST(alarm(100));
|
||||
|
||||
switch ( fork()) {
|
||||
case -1:
|
||||
tst_brkm(TBROK, cleanup, "fork failed, errno:%d %s",
|
||||
errno, strerror(errno));
|
||||
break;
|
||||
|
||||
case 0:
|
||||
TEST( alarm(0) );
|
||||
|
||||
if ( TEST_RETURN != 0 )
|
||||
tst_resm(TFAIL,
|
||||
"alarm(100), fork, alarm(0) child's alarm returned %d",
|
||||
TEST_RETURN);
|
||||
else if ( STD_FUNCTIONAL_TEST )
|
||||
tst_resm(TPASS,
|
||||
"alarm(100), fork, alarm(0) child's alarm returned %d",
|
||||
TEST_RETURN);
|
||||
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
Tst_count++;
|
||||
TEST( alarm(0) );
|
||||
if ( TEST_RETURN <= 0 || TEST_RETURN > 100 )
|
||||
tst_resm(TFAIL,
|
||||
"alarm(100), fork, alarm(0) parent's alarm returned %d",
|
||||
TEST_RETURN);
|
||||
|
||||
else if ( STD_FUNCTIONAL_TEST )
|
||||
tst_resm(TPASS,
|
||||
"alarm(100), fork, alarm(0) parent's alarm returned %d",
|
||||
TEST_RETURN);
|
||||
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
void trapper();
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
signal(SIGALRM, trapper);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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
|
||||
trapper(sig)
|
||||
int sig;
|
||||
{
|
||||
signal(SIGALRM, trapper);
|
||||
}
|
||||
|
||||
365
winsup/testsuite/winsup.api/ltp/asyncio02.c
Normal file
365
winsup/testsuite/winsup.api/ltp/asyncio02.c
Normal file
@ -0,0 +1,365 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/************************************************************
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
* Mendota Heights, Minnesota
|
||||
*
|
||||
* TEST IDENTIFIER: aiotcs02: write/close flushes data to the file
|
||||
*
|
||||
* PARENT DOCUMENT: aiotds01: kernel i/o
|
||||
*
|
||||
* AUTHOR: Barrie Kletscher
|
||||
*
|
||||
* CO-PILOT: Dave Baumgartner
|
||||
*
|
||||
* TEST ITEMS:
|
||||
* for each open flags set used:
|
||||
* 1. Multiple writes to a file work as specified for
|
||||
* more than BUFSIZ bytes.
|
||||
* 2. Multiple writes to a file work as specified for
|
||||
* BUFSIZ bytes.
|
||||
* 3. Multiple writes to a file work as specified for
|
||||
* lower than BUFSIZ bytes.
|
||||
*
|
||||
* INPUT SPECIFICATIONS:
|
||||
* Standard parse_opts supported options.
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
* Standard tst_res output format
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS:
|
||||
* This program uses the environment variable TMPDIR for the location
|
||||
* of the temporary directory.
|
||||
*
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS:
|
||||
* The program must be linked with tst_*.o and parse_opts.o.
|
||||
*
|
||||
* INTERCASE DEPENDENCIES:
|
||||
* NONE.
|
||||
*
|
||||
* DETAILED DESCRIPTION:
|
||||
* Attempt to get some memory to work with.
|
||||
* Call testrun writing (BUFSIZ + 1) bytes
|
||||
* Call testrun writing BUFSIZ bytes
|
||||
* Repeated call to testrun() with decreasing write sizes
|
||||
* less than BUFSIZ
|
||||
* End
|
||||
*
|
||||
* Start testrun()
|
||||
* Attempt to open a temporary file.
|
||||
* Write the memory to the file.
|
||||
* Attempt to close the file which also flushes the buffers.
|
||||
* Now check to see if the number of bytes written is the
|
||||
* same as the number of bytes in the file.
|
||||
* Cleanup
|
||||
*
|
||||
* BUGS:
|
||||
* NONE.
|
||||
*
|
||||
************************************************************/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/signal.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
#define FLAG O_RDWR | O_CREAT | O_TRUNC /* Flags used when opening temp tile */
|
||||
#define MODE 0777 /* Mode to open file with */
|
||||
#define WRITES 10 /* Number of times buffer is written */
|
||||
#define DECR 1000 /* Number of bytes decremented between */
|
||||
/* Calls to testrun() */
|
||||
#define OK -1 /* Return value from testrun() */
|
||||
|
||||
#define FNAME1 "aio02.1"
|
||||
#define FNAME2 "aio02.2"
|
||||
#define FNAME3 "aio02.3"
|
||||
|
||||
#define ERR_MSG1 "Bytes in file not equal to bytes written."
|
||||
#define ERR_MSG2 "Bytes in file (%d) not equal to bytes written (%d)."
|
||||
|
||||
char *dp; /* pointer to area of memory */
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
int testrun(int flag, int bytes, int ti);
|
||||
|
||||
char *TCID="asyncio02"; /* Test program identifier. */
|
||||
int TST_TOTAL=6; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
extern int Tst_nobuf; /* variable used to turn off tst_res buffering */
|
||||
|
||||
extern int errno;
|
||||
|
||||
int exp_enos[]={0}; /* Array of expected errnos */
|
||||
char mesg[150];
|
||||
char *filename; /* name of the temporary file */
|
||||
|
||||
char *Progname;
|
||||
int Open_flags;
|
||||
|
||||
int Flags[] = {
|
||||
O_RDWR | O_CREAT | O_TRUNC,
|
||||
O_RDWR | O_CREAT | O_TRUNC
|
||||
};
|
||||
|
||||
int Num_flags;
|
||||
|
||||
/***********************************************************************
|
||||
* MAIN
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
|
||||
int i; /* counter */
|
||||
int ret_val; /* return value from testrun call */
|
||||
int eok; /* everything is ok flag */
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
int flag_cnt;
|
||||
|
||||
Tst_nobuf=1;
|
||||
Num_flags = sizeof(Flags)/sizeof(int);
|
||||
TST_TOTAL= 3 * Num_flags;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options, and exit if there is an error
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for (flag_cnt=0; flag_cnt<Num_flags; flag_cnt++) {
|
||||
|
||||
/*
|
||||
* call testrun writing (BUFSIZ + 1) byte chunks
|
||||
*/
|
||||
|
||||
filename=FNAME1;
|
||||
if( testrun(Flags[flag_cnt],BUFSIZ+1,1) != OK)
|
||||
tst_resm(TFAIL,ERR_MSG1);
|
||||
|
||||
else if ( STD_FUNCTIONAL_TEST ) {
|
||||
tst_resm(TPASS,
|
||||
"More than BUFSIZE bytes multiple synchronous writes to a file check out ok");
|
||||
}
|
||||
|
||||
/*
|
||||
* call testrun writing BUFSIZ byte chunks
|
||||
*/
|
||||
|
||||
filename=FNAME2;
|
||||
if(testrun(Flags[flag_cnt],BUFSIZ,2) != OK) {
|
||||
tst_resm(TFAIL,ERR_MSG1);
|
||||
}
|
||||
else if ( STD_FUNCTIONAL_TEST ) {
|
||||
tst_resm(TPASS,
|
||||
"BUFSIZE bytes multiple synchronous writes to a file checks out ok");
|
||||
}
|
||||
|
||||
/*
|
||||
* while the byte chunks are greater than 0
|
||||
* call testrun() with decreasing chunk sizes
|
||||
*/
|
||||
|
||||
filename=FNAME3;
|
||||
eok=1;
|
||||
for(i = BUFSIZ-1; i >= 0; i -= DECR) {
|
||||
if((ret_val = testrun(Flags[flag_cnt],i,3)) != OK) {
|
||||
char output[80]; /* local output char string */
|
||||
|
||||
(void)sprintf(output,ERR_MSG2,ret_val,i*WRITES);
|
||||
tst_resm(TFAIL,output);
|
||||
}
|
||||
}
|
||||
|
||||
if ( eok && STD_FUNCTIONAL_TEST )
|
||||
tst_resm(TPASS,
|
||||
"Less than BUFSIZE bytes multiple synchronous writes to a file checks out ok");
|
||||
|
||||
}
|
||||
}
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* end main() */
|
||||
|
||||
/***********************************************************
|
||||
*
|
||||
* This function does the actual running of the tests.
|
||||
*
|
||||
***********************************************************/
|
||||
int
|
||||
testrun(int flag, int bytes, int ti)
|
||||
{
|
||||
|
||||
void cleanup();
|
||||
|
||||
int fildes, /* temporary file's descriptor */
|
||||
i; /* counter */
|
||||
|
||||
int ret;
|
||||
|
||||
struct stat buffer; /* buffer of memory required for stat command */
|
||||
|
||||
/*
|
||||
* Attempt to open a temporary file.
|
||||
*/
|
||||
|
||||
if((fildes = open(filename,flag,MODE)) == -1) {
|
||||
sprintf(mesg, "open failed, errno:%d", errno);
|
||||
tst_brkm(TBROK, cleanup, mesg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write the memory to the file.
|
||||
*/
|
||||
|
||||
for(i = 0; i < WRITES; i++) {
|
||||
TEST( write(fildes,dp,(unsigned)bytes) );
|
||||
|
||||
if( TEST_RETURN == -1) {
|
||||
sprintf(mesg, "write failed, errno:%d", errno);
|
||||
tst_brkm(TBROK, cleanup, mesg);
|
||||
}
|
||||
} /* end for() */
|
||||
|
||||
/*
|
||||
* Attempt to close the file which also flushes the buffers.
|
||||
*/
|
||||
|
||||
if(close(fildes) == -1) {
|
||||
sprintf(mesg, "close failed, errno:%d", errno);
|
||||
tst_brkm(TBROK, cleanup, mesg);
|
||||
}
|
||||
|
||||
ret=OK;
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
|
||||
/*
|
||||
* Now check to see if the number of bytes written is the
|
||||
* same as the number of bytes in the file.
|
||||
*/
|
||||
|
||||
if(stat(filename,&buffer) == -1) {
|
||||
sprintf(mesg, "stat failed, errno:%d", errno);
|
||||
tst_brkm(TBROK, cleanup, mesg);
|
||||
}
|
||||
|
||||
|
||||
if(buffer.st_size != (off_t)(bytes * WRITES)) {
|
||||
ret=(int)buffer.st_size;
|
||||
}
|
||||
}
|
||||
|
||||
if ( unlink(filename) == -1 ) {
|
||||
sprintf(mesg, "unlink failed, errno:%d", errno);
|
||||
tst_brkm(TBROK, cleanup, mesg);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
} /* end testrun() */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* create a temporary directory and go to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Indicate which errnos are expected */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
/*
|
||||
* Attempt to get some memory to work with.
|
||||
*/
|
||||
|
||||
if((dp = (char *)malloc((unsigned)BUFSIZ+1)) == NULL) {
|
||||
sprintf(mesg, "malloc failed, errno:%d", errno);
|
||||
tst_brkm(TBROK, cleanup, mesg);
|
||||
}
|
||||
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove temporary directory and all files in it. */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
220
winsup/testsuite/winsup.api/ltp/chdir02.c
Normal file
220
winsup/testsuite/winsup.api/ltp/chdir02.c
Normal file
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : chdir02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for chdir(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) chdir(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the chdir(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* chdir(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="chdir02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char *dirs[2] = { "/", "/tmp" };
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call chdir(2)
|
||||
*/
|
||||
TEST(chdir(dirs[lc%2]));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "chdir(%s) Failed, errno=%d : %s", dirs[lc%2],
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "chdir(%s) returned %d", dirs[lc%2], TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
260
winsup/testsuite/winsup.api/ltp/chmod02.c
Normal file
260
winsup/testsuite/winsup.api/ltp/chmod02.c
Normal file
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : chmod02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for chmod(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 8
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) chmod(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* The libcuts.a and libsys.a libraries must be included in
|
||||
* the compilation of this test.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the chmod(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* chmod(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="chmod02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
char fname[255];
|
||||
char *buf = "file contents\n";
|
||||
|
||||
int Modes[] = {0, 07, 070, 0700, 0777, 02777, 04777, 06777};
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
int ind;
|
||||
int mode;
|
||||
|
||||
TST_TOTAL = sizeof(Modes) / sizeof(int);
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for (ind=0; ind<TST_TOTAL; ind++) {
|
||||
mode=Modes[ind];
|
||||
|
||||
/*
|
||||
* Call chmod(2) with mode argument on fname
|
||||
*/
|
||||
TEST(chmod(fname, mode));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
tst_resm(TFAIL, "chmod(%s, %#o) Failed, errno=%d : %s", fname,
|
||||
mode, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "chmod(%s, %#o) returned %d", fname,
|
||||
mode, TEST_RETURN);
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
int fd;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
strcat(fname, "tfile");
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
} else if (write(fd, &buf, strlen(buf)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"write(%s, &buf, strlen(buf)) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
} else if (close(fd) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"close(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
244
winsup/testsuite/winsup.api/ltp/chown01.c
Normal file
244
winsup/testsuite/winsup.api/ltp/chown01.c
Normal file
@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : chown01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for chown(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) chown(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the chown(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* chown(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="chown01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd, uid, gid;
|
||||
char *buf = "davef";
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call chown(2)
|
||||
*/
|
||||
TEST(chown(fname, uid,gid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "chown(%s, %d,%d) Failed, errno=%d : %s", fname, uid, gid,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "chown(%s, %d,%d) returned %d", fname, uid, gid, TEST_RETURN);
|
||||
}
|
||||
} /* end else */
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* create a temp dir and cd to it. */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
/* set uid and gid */
|
||||
uid=geteuid();
|
||||
gid=getegid();
|
||||
|
||||
sprintf(fname,"t_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
} else if (write(fd, &buf, strlen(buf)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "write(%s, &buf, strlen(buf)) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
} else if (close(fd) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove temp dir and files */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
241
winsup/testsuite/winsup.api/ltp/close08.c
Normal file
241
winsup/testsuite/winsup.api/ltp/close08.c
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : close08
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for close(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) close(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the close(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* close(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="close08"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
if ((fd=open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
/*
|
||||
* Call close(2)
|
||||
*/
|
||||
TEST(close(fd));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "close(%s) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "close(%s) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
if (unlink(fname) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "unlink(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
246
winsup/testsuite/winsup.api/ltp/creat09.c
Normal file
246
winsup/testsuite/winsup.api/ltp/creat09.c
Normal file
@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : creat09
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for creat(2) using 0700 argument.
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) creat(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the creat(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* creat(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="creat09"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
*******************************************
|
||||
* Call creat(2) with 0700 argument on fname
|
||||
*******************************************
|
||||
*/
|
||||
TEST(creat(fname, 0700));
|
||||
|
||||
/* check return code */
|
||||
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "creat(%s, 0700) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "creat(%s, 0700) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
/* close and remove file, possibly for next loop */
|
||||
if (close(TEST_RETURN) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"close(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
} else if (unlink(fname) == -1) {
|
||||
tst_resm(TWARN, "unlink(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
261
winsup/testsuite/winsup.api/ltp/dup01.c
Normal file
261
winsup/testsuite/winsup.api/ltp/dup01.c
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : dup01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for dup(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) dup(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the dup(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* dup(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
char *TCID="dup01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char Fname[255];
|
||||
int Fd;
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call dup(2)
|
||||
*/
|
||||
TEST( dup(Fd) );
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "dup(%s) Failed, errno=%d : %s", Fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "dup(%s) returned %d", Fname, TEST_RETURN);
|
||||
}
|
||||
|
||||
/* close the new file so loops do not open too many files */
|
||||
if (close(TEST_RETURN) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/*
|
||||
* Initialize Fd in case we get a quick signal
|
||||
*/
|
||||
Fd=-1;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(Fname, "dupfile");
|
||||
if ((Fd = open(Fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the open file we've been dup'ing */
|
||||
if (Fd != -1) {
|
||||
if (close(Fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
Fd=-1;
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
246
winsup/testsuite/winsup.api/ltp/dup02.c
Normal file
246
winsup/testsuite/winsup.api/ltp/dup02.c
Normal file
@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : dup02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Negative test for dup(2) with bad fd.
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 2
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 06/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1-?.) dup(2) returns -1 with errno set to EBADF...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
* Standard tst_res formatted output
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Loop through the test cases
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* if doing functional check
|
||||
* check if errno set correctly, report results
|
||||
* Otherwise, Issue a FAIL message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
char *TCID="dup02"; /* Test program identifier. */
|
||||
int TST_TOTAL=2; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int Fds[] = { -1, 1500 };
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
int nfds = sizeof(Fds) / sizeof(int);
|
||||
int ind;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for (ind=0; ind<nfds; ind++) {
|
||||
|
||||
/*
|
||||
* Call dup(2)
|
||||
*/
|
||||
TEST( dup(Fds[ind]) );
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_ERRNO == EBADF ) {
|
||||
tst_resm(TPASS, "dup(%d) Failed, errno=%d : %s", Fds[ind],
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"dup(%d) Failed, errno=%d %s, expected %d (EBADF)",
|
||||
Fds[ind], TEST_ERRNO, strerror(TEST_ERRNO), EBADF);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tst_resm(TFAIL, "dup(%d) returned %d, expected -1, errno:%d (EBADF)",
|
||||
Fds[ind], TEST_RETURN, EBADF);
|
||||
|
||||
/* close the new file so loops do not open too many files */
|
||||
if (close(TEST_RETURN) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "close(%d) Failed, errno=%d : %s",
|
||||
TEST_RETURN, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
297
winsup/testsuite/winsup.api/ltp/dup04.c
Normal file
297
winsup/testsuite/winsup.api/ltp/dup04.c
Normal file
@ -0,0 +1,297 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : dup04
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for dup(2) of a system pipe descriptor
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 2
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 06/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) dup(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the dup(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* dup(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
char *TCID="dup04"; /* Test program identifier. */
|
||||
int TST_TOTAL=2; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int Fd[2];
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call dup(2) for read side
|
||||
*/
|
||||
TEST( dup(Fd[0]) );
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "dup(%d) read side of syspipe Failed, errno=%d : %s", Fd[0],
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "dup(%d) read side of syspipe returned %d", Fd[0],
|
||||
TEST_RETURN);
|
||||
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
|
||||
/* close the new file so loops do not open too many files */
|
||||
if (close(TEST_RETURN) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "close(%d) Failed, errno=%d : %s",
|
||||
TEST_RETURN, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Call dup(2) for write side
|
||||
*/
|
||||
TEST( dup(Fd[1]) );
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "dup(%d) write side of syspipe Failed, errno=%d : %s", Fd[1],
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "dup(%d) write side of syspipe returned %d", Fd[1],
|
||||
TEST_RETURN);
|
||||
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
|
||||
/* close the new file so loops do not open too many files */
|
||||
if (close(TEST_RETURN) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "close(%d) Failed, errno=%d : %s",
|
||||
TEST_RETURN, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/*
|
||||
* Initialize Fd in case we get a quick signal
|
||||
*/
|
||||
Fd[0]=-1;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
if ( pipe(Fd) == -1 ) {
|
||||
tst_brkm(TBROK, cleanup, "pipe(&Fd) Failed, errno=%d : %s",
|
||||
errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
int ind;
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the open file we've been dup'ing */
|
||||
if (Fd[0] != -1) {
|
||||
for (ind=0; ind<2; ind++) {
|
||||
if (close(Fd[ind]) == -1) {
|
||||
tst_resm(TWARN, "close(%d) Failed, errno=%d : %s",
|
||||
Fd[ind], errno, strerror(errno));
|
||||
}
|
||||
Fd[ind]=-1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
266
winsup/testsuite/winsup.api/ltp/dup05.c
Normal file
266
winsup/testsuite/winsup.api/ltp/dup05.c
Normal file
@ -0,0 +1,266 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : dup05
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for dup(2) of a named pipe descriptor
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 06/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) dup(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the dup(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* dup(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
char *TCID="dup05"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char Fname[255];
|
||||
int Fd;
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call dup(2)
|
||||
*/
|
||||
TEST( dup(Fd) );
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "dup(%s) Failed, errno=%d : %s", Fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "dup(%s) returned %d", Fname, TEST_RETURN);
|
||||
}
|
||||
|
||||
/* close the new file so loops do not open too many files */
|
||||
if (close(TEST_RETURN) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/*
|
||||
* Initialize Fd in case we get a quick signal
|
||||
*/
|
||||
Fd=-1;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(Fname, "dupfile");
|
||||
if ( mkfifo(Fname, 0777) == -1 ) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"mkfifo(%s, 0700) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
if ((Fd = open(Fname, O_RDWR, 0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR, 0700) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the open file we've been dup'ing */
|
||||
if (Fd != -1) {
|
||||
if (close(Fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
Fd=-1;
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
258
winsup/testsuite/winsup.api/ltp/execl01.c
Normal file
258
winsup/testsuite/winsup.api/ltp/execl01.c
Normal file
@ -0,0 +1,258 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : execl01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for execl(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 06/01/02
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) execl(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the execl(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* execl(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="execl01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
extern int Tst_nobuf; /* used to turn off buffering in tst_ routines */
|
||||
|
||||
int exp_enos[]={0, 0}; /* Zero terminated list of expected errnos */
|
||||
|
||||
int pid; /* process id from fork */
|
||||
int status; /* status returned from waitpid */
|
||||
|
||||
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
Tst_nobuf=1; /* turn off buffering in tst_ routines */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* fork, then call execl from child
|
||||
*/
|
||||
switch(pid=fork()) {
|
||||
case 0: /* CHILD - Call execl(2) */
|
||||
execl("test", "test", NULL);
|
||||
/* should not get here!! if we do, the parent will fail the Test Case */
|
||||
exit(errno);
|
||||
case -1: /* ERROR!!! exit now!!*/
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"Unable to fork a child process to exec over! Errno:%d,:%s",
|
||||
errno, strerror(errno));
|
||||
break;
|
||||
default:
|
||||
waitpid(pid, &status, 0);
|
||||
if ( WIFEXITED(status) ) {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "execl - properly exec's a simple program..");
|
||||
}
|
||||
} else {
|
||||
TEST_ERROR_LOG(WEXITSTATUS(status));
|
||||
tst_resm(TFAIL, "Child process did not terminate properly, status=%d", status);
|
||||
}
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp dir and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/*
|
||||
* Send out info message that timing and errnolog info is not
|
||||
* available because of the use of a child process for each exec
|
||||
*/
|
||||
if ( STD_TIMING_ON )
|
||||
tst_resm(TINFO, "There are NO timing statistics produced by this test.\n\
|
||||
This is because the test forks to create a child process which then calls execl.\n\
|
||||
The TEST macro is NOT used.");
|
||||
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove files and temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
257
winsup/testsuite/winsup.api/ltp/execle01.c
Normal file
257
winsup/testsuite/winsup.api/ltp/execle01.c
Normal file
@ -0,0 +1,257 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : execle01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for execle(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 06/01/02
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) execle(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the execle(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* execle(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="execle01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
extern int Tst_nobuf; /* used to turn off buffering in tst_ routines */
|
||||
|
||||
int exp_enos[]={0, 0}; /* Zero terminated list of expected errnos */
|
||||
|
||||
int pid; /* process id from fork */
|
||||
int status; /* status returned from waitpid */
|
||||
extern char **environ; /* pointer to this processes env, to pass along */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
Tst_nobuf=1; /* turn off buffering in tst_ routines */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* fork, then call execle from child
|
||||
*/
|
||||
switch(pid=fork()) {
|
||||
case 0: /* CHILD - Call execle(2) */
|
||||
execle("test", "test", 0, environ);
|
||||
/* should not get here!! if we do, the parent will fail the Test Case */
|
||||
exit(errno);
|
||||
case -1: /* ERROR!!! exit now!!*/
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"Unable to fork a child process to exec over! Errno:%d,:%s",
|
||||
errno, strerror(errno));
|
||||
break;
|
||||
default:
|
||||
waitpid(pid, &status, 0);
|
||||
if ( WIFEXITED(status) ) {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "execle - properly exec's a simple program..");
|
||||
}
|
||||
} else {
|
||||
TEST_ERROR_LOG(WEXITSTATUS(status));
|
||||
tst_resm(TFAIL, "Child process did not terminate properly, status=%d", status);
|
||||
}
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp dir and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/*
|
||||
* Send out info message that timing and errnolog info is not
|
||||
* available because of the use of a child process for each exec
|
||||
*/
|
||||
if ( STD_TIMING_ON )
|
||||
tst_resm(TINFO, "There are NO timing statistics produced by this test.\n\
|
||||
This is because the test forks to create a child process which then calls execle.\n\
|
||||
The TEST macro is NOT used.");
|
||||
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove files and temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
256
winsup/testsuite/winsup.api/ltp/execlp01.c
Normal file
256
winsup/testsuite/winsup.api/ltp/execlp01.c
Normal file
@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : execlp01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for execlp(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 06/01/02
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) execlp(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the execlp(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* execlp(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="execlp01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
extern int Tst_nobuf; /* used to turn off buffering in tst_ routines */
|
||||
|
||||
int exp_enos[]={0, 0}; /* Zero terminated list of expected errnos */
|
||||
|
||||
int pid; /* process id from fork */
|
||||
int status; /* status returned from waitpid */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
Tst_nobuf=1; /* turn off buffering in tst_ routines */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* fork, then call execlp from child
|
||||
*/
|
||||
switch(pid=fork()) {
|
||||
case 0: /* CHILD - Call execlp(2) */
|
||||
execlp("/usr/bin/test", "/usr/bin/test", 0);
|
||||
/* should not get here!! if we do, the parent will fail the Test Case */
|
||||
exit(errno);
|
||||
case -1: /* ERROR!!! exit now!!*/
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"Unable to fork a child process to exec over! Errno:%d,:%s",
|
||||
errno, strerror(errno));
|
||||
break;
|
||||
default:
|
||||
waitpid(pid, &status, 0);
|
||||
if ( WIFEXITED(status) ) {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "execlp - properly exec's a simple program..");
|
||||
}
|
||||
} else {
|
||||
TEST_ERROR_LOG(WEXITSTATUS(status));
|
||||
tst_resm(TFAIL, "Child process did not terminate properly, status=%d", status);
|
||||
}
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp dir and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/*
|
||||
* Send out info message that timing and errnolog info is not
|
||||
* available because of the use of a child process for each exec
|
||||
*/
|
||||
if ( STD_TIMING_ON )
|
||||
tst_resm(TINFO, "There are NO timing statistics produced by this test.\n\
|
||||
This is because the test forks to create a child process which then calls execlp.\n\
|
||||
The TEST macro is NOT used.");
|
||||
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove files and temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
257
winsup/testsuite/winsup.api/ltp/execv01.c
Normal file
257
winsup/testsuite/winsup.api/ltp/execv01.c
Normal file
@ -0,0 +1,257 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : execv01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for execv(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 06/01/02
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) execv(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the execv(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* execv(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="execv01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
extern int Tst_nobuf; /* used to turn off buffering in tst_ routines */
|
||||
|
||||
int exp_enos[]={0, 0}; /* Zero terminated list of expected errnos */
|
||||
|
||||
int pid; /* process id from fork */
|
||||
int status; /* status returned from waitpid */
|
||||
char *args[2]={"/usr/bin/test", 0}; /* argument list for execv call */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
Tst_nobuf=1; /* turn off buffering in tst_ routines */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* fork, then call execv from child
|
||||
*/
|
||||
switch(pid=fork()) {
|
||||
case 0: /* CHILD - Call execv(2) */
|
||||
execv("/usr/bin/test", args);
|
||||
/* should not get here!! if we do, the parent will fail the Test Case */
|
||||
exit(errno);
|
||||
case -1: /* ERROR!!! exit now!!*/
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"Unable to fork a child process to exec over! Errno:%d,:%s",
|
||||
errno, strerror(errno));
|
||||
break;
|
||||
default:
|
||||
waitpid(pid, &status, 0);
|
||||
if ( WIFEXITED(status) ) {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "execv - properly exec's a simple program..");
|
||||
}
|
||||
} else {
|
||||
TEST_ERROR_LOG(WEXITSTATUS(status));
|
||||
tst_resm(TFAIL, "Child process did not terminate properly, status=%d", status);
|
||||
}
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp dir and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/*
|
||||
* Send out info message that timing and errnolog info is not
|
||||
* available because of the use of a child process for each exec
|
||||
*/
|
||||
if ( STD_TIMING_ON )
|
||||
tst_resm(TINFO, "There are NO timing statistics produced by this test.\n\
|
||||
This is because the test forks to create a child process which then calls execv.\n\
|
||||
The TEST macro is NOT used.");
|
||||
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove files and temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
258
winsup/testsuite/winsup.api/ltp/execve01.c
Normal file
258
winsup/testsuite/winsup.api/ltp/execve01.c
Normal file
@ -0,0 +1,258 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : execve01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for execve(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 06/01/02
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) execve(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the execve(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* execve(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="execve01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
extern int Tst_nobuf; /* used to turn off buffering in tst_ routines */
|
||||
|
||||
int exp_enos[]={0, 0}; /* Zero terminated list of expected errnos */
|
||||
|
||||
int pid; /* process id from fork */
|
||||
int status; /* status returned from waitpid */
|
||||
char *args[2]={"/usr/bin/test", 0}; /* argument list for execve call */
|
||||
extern char **environ; /* pointer to this processes env, to pass along */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
Tst_nobuf=1; /* turn off buffering in tst_ routines */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* fork, then call execve from child
|
||||
*/
|
||||
switch(pid=fork()) {
|
||||
case 0: /* CHILD - Call execve(2) */
|
||||
execve("/usr/bin/test", args, environ);
|
||||
/* should not get here!! if we do, the parent will fail the Test Case */
|
||||
exit(errno);
|
||||
case -1: /* ERROR!!! exit now!!*/
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"Unable to fork a child process to exec over! Errno:%d,:%s",
|
||||
errno, strerror(errno));
|
||||
break;
|
||||
default:
|
||||
waitpid(pid, &status, 0);
|
||||
if ( WIFEXITED(status) ) {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "execve - properly exec's a simple program..");
|
||||
}
|
||||
} else {
|
||||
TEST_ERROR_LOG(WEXITSTATUS(status));
|
||||
tst_resm(TFAIL, "Child process did not terminate properly, status=%d", status);
|
||||
}
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp dir and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/*
|
||||
* Send out info message that timing and errnolog info is not
|
||||
* available because of the use of a child process for each exec
|
||||
*/
|
||||
if ( STD_TIMING_ON )
|
||||
tst_resm(TINFO, "There are NO timing statistics produced by this test.\n\
|
||||
This is because the test forks to create a child process which then calls execve.\n\
|
||||
The TEST macro is NOT used.");
|
||||
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove files and temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
257
winsup/testsuite/winsup.api/ltp/execvp01.c
Normal file
257
winsup/testsuite/winsup.api/ltp/execvp01.c
Normal file
@ -0,0 +1,257 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : execvp01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for execvp(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 06/01/02
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) execvp(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the execvp(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* execvp(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="execvp01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
extern int Tst_nobuf; /* used to turn off buffering in tst_ routines */
|
||||
|
||||
int exp_enos[]={0, 0}; /* Zero terminated list of expected errnos */
|
||||
|
||||
int pid; /* process id from fork */
|
||||
int status; /* status returned from waitpid */
|
||||
char *args[2]={"/usr/bin/test", 0}; /* argument list for execvp call */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
Tst_nobuf=1; /* turn off buffering in tst_ routines */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* fork, then call execvp from child
|
||||
*/
|
||||
switch(pid=fork()) {
|
||||
case 0: /* CHILD - Call execvp(2) */
|
||||
execvp("/usr/bin/test", args);
|
||||
/* should not get here!! if we do, the parent will fail the Test Case */
|
||||
exit(errno);
|
||||
case -1: /* ERROR!!! exit now!!*/
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"Unable to fork a child process to exec over! Errno:%d,:%s",
|
||||
errno, strerror(errno));
|
||||
break;
|
||||
default:
|
||||
waitpid(pid, &status, 0);
|
||||
if ( WIFEXITED(status) ) {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "execvp - properly exec's a simple program..");
|
||||
}
|
||||
} else {
|
||||
TEST_ERROR_LOG(WEXITSTATUS(status));
|
||||
tst_resm(TFAIL, "Child process did not terminate properly, status=%d", status);
|
||||
}
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp dir and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/*
|
||||
* Send out info message that timing and errnolog info is not
|
||||
* available because of the use of a child process for each exec
|
||||
*/
|
||||
if ( STD_TIMING_ON )
|
||||
tst_resm(TINFO, "There are NO timing statistics produced by this test.\n\
|
||||
This is because the test forks to create a child process which then calls execvp.\n\
|
||||
The TEST macro is NOT used.");
|
||||
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove files and temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
241
winsup/testsuite/winsup.api/ltp/fchmod01.c
Normal file
241
winsup/testsuite/winsup.api/ltp/fchmod01.c
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fchmod01
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fchmod(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fchmod(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fchmod(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fchmod01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
char *buf = "davef";
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call fchmod(2)
|
||||
*/
|
||||
TEST(fchmod(fd, 0700));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "fchmod(%s, 0700) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "fchmod(%s, 0700) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
} else if (write(fd, &buf, strlen(buf)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "write(%s, &buf, strlen(buf)) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the open file wev'e been chmoding */
|
||||
if (close(fd) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
234
winsup/testsuite/winsup.api/ltp/fchown01.c
Normal file
234
winsup/testsuite/winsup.api/ltp/fchown01.c
Normal file
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fchown01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fchown(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 02/14/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fchown(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fchown(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fchown(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fchown01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int Fd; /* file descriptor for fchown */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/* Call fchown(2) just once */
|
||||
TEST(fchown(Fd, geteuid(), getegid()));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL,
|
||||
"fchown(Fd, geteuid(), getegid()) failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* Perform functional verification here */
|
||||
tst_resm(TPASS,
|
||||
"fchown(Fd, geteuid(), getegid()) returned %d",
|
||||
TEST_RETURN);
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a tempdir and change to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* open a file for read/write */
|
||||
sprintf(fname, "./tmpfile.%d", getpid());
|
||||
if ( (Fd=open(fname, O_RDWR|O_CREAT, 0700)) == -1 )
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"Unable to open %s for read/write. Error:%d, %s",
|
||||
fname, errno, strerror(errno)); /* this exits */
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
close(Fd);
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove temp dir and files */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
244
winsup/testsuite/winsup.api/ltp/fcntl02.c
Normal file
244
winsup/testsuite/winsup.api/ltp/fcntl02.c
Normal file
@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fcntl02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fcntl(2) using F_DUPFD argument.
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fcntl(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fcntl(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fcntl(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fcntl02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call fcntl(2) with F_DUPFD argument on fname
|
||||
*/
|
||||
TEST(fcntl(fd, F_DUPFD, 0));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "fcntl(%s, F_DUPFD, 0) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "fcntl(%s, F_DUPFD, 0) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
if (close(TEST_RETURN) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the file we've had open */
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
240
winsup/testsuite/winsup.api/ltp/fcntl03.c
Normal file
240
winsup/testsuite/winsup.api/ltp/fcntl03.c
Normal file
@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fcntl03
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fcntl(2) using F_GETFD argument.
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fcntl(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fcntl(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fcntl(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fcntl03"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call fcntl(2) with F_GETFD argument on fname
|
||||
*/
|
||||
TEST(fcntl(fd, F_GETFD, 0));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "fcntl(%s, F_GETFD, 0) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "fcntl(%s, F_GETFD, 0) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
239
winsup/testsuite/winsup.api/ltp/fcntl04.c
Normal file
239
winsup/testsuite/winsup.api/ltp/fcntl04.c
Normal file
@ -0,0 +1,239 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fcntl04
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fcntl(2) using F_GETFL argument.
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fcntl(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fcntl(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fcntl(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fcntl04"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call fcntl(2) with F_GETFL argument on fname
|
||||
*/
|
||||
TEST(fcntl(fd, F_GETFL, 0));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "fcntl(%s, F_GETFL, 0) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "fcntl(%s, F_GETFL, 0) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
249
winsup/testsuite/winsup.api/ltp/fcntl05.c
Normal file
249
winsup/testsuite/winsup.api/ltp/fcntl05.c
Normal file
@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fcntl05
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fcntl(2) using F_GETLK argument.
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fcntl(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fcntl(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fcntl(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fcntl05"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
struct flock flocks;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
flocks.l_type = F_RDLCK;
|
||||
/*
|
||||
* Call fcntl(2) with F_GETLK argument on fname
|
||||
*/
|
||||
TEST(fcntl(fd, F_GETLK, &flocks));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "fcntl(%s, F_GETLK, &flocks) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "fcntl(%s, F_GETLK, &flocks) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* set needed flags in the flocks structure */
|
||||
flocks.l_whence=1;
|
||||
flocks.l_start=0;
|
||||
flocks.l_len=0;
|
||||
flocks.l_pid=getpid();
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Close the file we have open */
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
426
winsup/testsuite/winsup.api/ltp/fcntl07.c
Normal file
426
winsup/testsuite/winsup.api/ltp/fcntl07.c
Normal file
@ -0,0 +1,426 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fcntl07
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Close-On-Exec functional test
|
||||
*
|
||||
* PARENT DOCUMENT : none
|
||||
*
|
||||
* TEST CASE TOTAL : 2
|
||||
*
|
||||
* WALL CLOCK TIME : 5
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Glen Overby
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 08/11/93
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) test close-on-exec with a regular file
|
||||
* 2.) test close-on-exec with a system pipe
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
*
|
||||
* Standard arguments accepted by parse_opts(3).
|
||||
*
|
||||
* The -t (timing) and -e options apply to the fcntl(.., F_SETFD, ..)
|
||||
* system call.
|
||||
*
|
||||
* -T fd : If this option is given, the program runs as "test_open",
|
||||
* testing <fd> to see if it is open or not and exiting
|
||||
* accordingly:
|
||||
* 0 not open (EBADF from fcntl(..., F_GETFD, ...))
|
||||
* 3 no error from fcntl
|
||||
* errno fcntl returned an error other than EBADF
|
||||
*
|
||||
* -F name : File to open. Must be an absolute path
|
||||
* and the file must be writable;
|
||||
* -n program: path to the 'test_open' program
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
* This test uses the cuts-style test_res format output consisting of:
|
||||
*
|
||||
* test-name PASS/FAIL/BROK message
|
||||
*
|
||||
* the message will tell what type of test and, if it failed, indicate
|
||||
* what the failure was.
|
||||
*
|
||||
* DURATION
|
||||
* Terminates
|
||||
*
|
||||
* SIGNALS
|
||||
* None
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* If this test is not called with a full pathname, it must be able
|
||||
* to find itself on $PATH
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* none
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Create and make current a temporary directory.
|
||||
* Open a regular file for writing
|
||||
* Create a system pipe
|
||||
* Create a named pipe and open it for writing
|
||||
*
|
||||
* Test:
|
||||
* Set the file descriptor for close-on-exec
|
||||
* Fork
|
||||
* Child execlp's the program "test_open".
|
||||
* If the exec fails, exit "2"
|
||||
* Parent waits
|
||||
* Report results.
|
||||
*
|
||||
* Cleanup:
|
||||
* Close file and pipes
|
||||
* Remove the temporary directory
|
||||
*
|
||||
* BUGS
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
#include "search_path.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
void help();
|
||||
|
||||
char *TCID="fcntl07"; /* Test program identifier. */
|
||||
int TST_TOTAL=2; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
|
||||
|
||||
/* for parse_opts */
|
||||
int fflag, Tflag; /* binary flags: opt or not */
|
||||
char *fopt, *Topt; /* option arguments */
|
||||
|
||||
option_t options[] = {
|
||||
{ "F:", &fflag, &fopt }, /* -F filename */
|
||||
{ "T:", &Tflag, &Topt }, /* -T <fd> exec'ed by test: test FD */
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
int stat_loc; /* for waitpid() */
|
||||
|
||||
int file_fd, pipe_fds[2];
|
||||
/* file descriptors for a file and a system pipe */
|
||||
#define DEFAULT_FILE "DefaultFileName"
|
||||
char *File1 = DEFAULT_FILE;
|
||||
|
||||
#define DEFAULT_SUBPROG "test_open"
|
||||
char *openck = DEFAULT_SUBPROG; /* support program name to check for open FD */
|
||||
char subprog_path[_POSIX_PATH_MAX]; /* path to exec "openck" with */
|
||||
#define STRSIZE 255
|
||||
|
||||
int *testfds[] = {
|
||||
&file_fd, &pipe_fds[1], 0
|
||||
};
|
||||
|
||||
char *testfdtypes[] = {
|
||||
"regular file",
|
||||
"write side of system pipe",
|
||||
};
|
||||
|
||||
int test_open(char *arg);
|
||||
int do_exec(char *prog, int fd, char *tcd);
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
int exec_return; /* return from do_exec */
|
||||
int **tcp; /* testcase pointer (pointer to FD) */
|
||||
char **tcd; /* testcase description pointer */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options, and exit if there is an error
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, options, &help)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
if(fflag) /* -F option */
|
||||
File1 = fopt;
|
||||
|
||||
if(Tflag) { /* -T option */
|
||||
exit(test_open(Topt));
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup(av[0]);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for(tcp = testfds, tcd = testfdtypes; *tcp; tcp++, tcd++) {
|
||||
|
||||
TEST(fcntl(**tcp, F_SETFD, FD_CLOEXEC));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "fcntl(%s[%d], F_SETFD, FD_CLOEXEC) Failed, errno=%d : %s",
|
||||
*tcd, **tcp, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/*************************************************************
|
||||
* only perform functional verification if flag set
|
||||
* (-f not given)
|
||||
*************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
|
||||
exec_return = do_exec(subprog_path, **tcp, *tcd);
|
||||
|
||||
switch(exec_return) {
|
||||
case -1:
|
||||
tst_resm(TBROK, "fork failed. Errno %s [%d]",
|
||||
strerror(errno), errno);
|
||||
break;
|
||||
case 1:
|
||||
tst_resm(TBROK, "waitpid return was 0%o", stat_loc);
|
||||
break;
|
||||
case 2:
|
||||
tst_resm(TBROK, "exec failed"); /* errno was in child */
|
||||
break;
|
||||
case 0:
|
||||
tst_resm(TPASS, "%s child exited 0, indicating that the file was closed",
|
||||
*tcd);
|
||||
break;
|
||||
default:
|
||||
tst_resm(TFAIL, "%s child exited non-zero, %d", *tcd,
|
||||
exec_return);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup(char *path)
|
||||
{
|
||||
search_path(path, subprog_path, X_OK, 1);
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* create a temporary directory and go to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* set up a regular file */
|
||||
if((file_fd=open(File1, O_CREAT|O_RDWR, 0666)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "Open of file %s failed errno %d (%s)\n", File1, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* set up a system pipe (write side gets CLOSE-ON-EXEC) */
|
||||
pipe(pipe_fds);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close everything */
|
||||
close(file_fd);
|
||||
close(pipe_fds[0]);
|
||||
close(pipe_fds[1]);
|
||||
|
||||
/* remove temporary directory and all files in it. */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
/***************************************************************************
|
||||
* issue a help message
|
||||
***************************************************************************/
|
||||
void
|
||||
help()
|
||||
{
|
||||
printf("-T fd : If this option is given, the program runs as 'test_open'\n");
|
||||
printf(" testing <fd> to see if it is open or not and exiting accordingly\n");
|
||||
printf("-F name : File to open. Must be an absolute path,\n");
|
||||
printf(" and the file must be writable\n");
|
||||
printf("-n program: path to the 'test_open' program\n");
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Perform an exec, then wait for the child to terminate.
|
||||
* The child's termination status determines the success of the test
|
||||
*
|
||||
* Return codes:
|
||||
* -1 BROK fork failed
|
||||
* 1 BROK waitpid returned != exit status
|
||||
* <else> ???? exit code from child:
|
||||
* 2 BROK exec failed
|
||||
* 0 PASS fd was properly closed
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
do_exec(char *prog, int fd, char *tcd)
|
||||
{
|
||||
int pid;
|
||||
char pidname[STRSIZE];
|
||||
#ifdef DEBUG
|
||||
int rc, status; /* for the fcntl */
|
||||
#endif
|
||||
|
||||
/* set up arguments to exec'ed child */
|
||||
sprintf(pidname, "%d", fd);
|
||||
|
||||
#ifdef DEBUG
|
||||
rc = fcntl(fd, F_GETFD, &status);
|
||||
printf("%s: fd = %d rc = %d status= %d, errno= %d\n", tcd, fd, rc, status, errno);
|
||||
#endif
|
||||
|
||||
switch(pid=fork()) {
|
||||
case -1:
|
||||
return(-1);
|
||||
case 0: /* child */
|
||||
execlp(prog, openck, "-T", pidname, 0);
|
||||
|
||||
/* the ONLY reason to do this is to get the errno printed out */
|
||||
fprintf(stderr, "exec(%s, %s, -T, %s) failed. Errno %s [%d]\n",
|
||||
prog, openck, pidname, strerror(errno), errno);
|
||||
exit(2);
|
||||
default: /* parent */
|
||||
waitpid(pid, &stat_loc, 0);
|
||||
if(WIFEXITED(stat_loc)) {
|
||||
return(WEXITSTATUS(stat_loc));
|
||||
} else {
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* PROGRAM TITLE : Test if a named file descriptor is open
|
||||
* This function is called when fcntcs07 is called with the -T option.
|
||||
* It tests if a file descriptor is open and exits accordingly.
|
||||
*/
|
||||
int
|
||||
test_open(char *arg)
|
||||
{
|
||||
int fd, rc;
|
||||
int status;
|
||||
|
||||
fd = atoi(arg);
|
||||
|
||||
rc = fcntl(fd, F_GETFD, &status);
|
||||
|
||||
#ifdef DEBUG_T
|
||||
printf("%s: fd = %d rc = %d status= %d, errno= %d\n", openck, fd, rc,
|
||||
status, errno);
|
||||
#endif
|
||||
|
||||
if(rc == -1 && errno == EBADF) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(rc != -1)
|
||||
exit(3);
|
||||
|
||||
exit(errno);
|
||||
return -1; /* to remove compiler warning on IRIX */
|
||||
}
|
||||
427
winsup/testsuite/winsup.api/ltp/fcntl07B.c
Normal file
427
winsup/testsuite/winsup.api/ltp/fcntl07B.c
Normal file
@ -0,0 +1,427 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fcntl07B
|
||||
* <same
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Close-On-Exec of named pipe functional test
|
||||
*
|
||||
* PARENT DOCUMENT : none
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 5
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan :copied from fcntcs07 written by Glen Overby
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 08/11/93
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) test close-on-exec with a named pipe
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
*
|
||||
* Standard arguments accepted by parse_opts(3).
|
||||
*
|
||||
* The -t (timing) and -e options apply to the fcntl(.., F_SETFD, ..)
|
||||
* system call.
|
||||
*
|
||||
* -T fd : If this option is given, the program runs as "test_open",
|
||||
* testing <fd> to see if it is open or not and exiting
|
||||
* accordingly:
|
||||
* 0 not open (EBADF from fcntl(..., F_GETFD, ...))
|
||||
* 3 no error from fcntl
|
||||
* errno fcntl returned an error other than EBADF
|
||||
*
|
||||
* -F name : File to open. Must be an absolute path
|
||||
* and the file must be writable;
|
||||
* -n program: path to the 'test_open' program
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
* This test uses the cuts-style test_res format output consisting of:
|
||||
*
|
||||
* test-name PASS/FAIL/BROK message
|
||||
*
|
||||
* the message will tell what type of test and, if it failed, indicate
|
||||
* what the failure was.
|
||||
*
|
||||
* DURATION
|
||||
* Terminates
|
||||
*
|
||||
* SIGNALS
|
||||
* None
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* If this test is not called with a full pathname, it must be able
|
||||
* to find itself on $PATH
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* none
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Create and make current a temporary directory.
|
||||
* Create a named pipe and open it for writing
|
||||
*
|
||||
* Test:
|
||||
* Set the file descriptor for close-on-exec
|
||||
* Fork
|
||||
* Child execlp's the program "test_open".
|
||||
* If the exec fails, exit "2"
|
||||
* Parent waits
|
||||
* Report results.
|
||||
*
|
||||
* Cleanup:
|
||||
* Close file and pipes
|
||||
* Remove the temporary directory
|
||||
*
|
||||
* BUGS
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
#include "search_path.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
void help();
|
||||
|
||||
char *TCID="fcntl07B"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
|
||||
/* for parse_opts */
|
||||
int fflag, Tflag; /* binary flags: opt or not */
|
||||
char *fopt, *Topt; /* option arguments */
|
||||
|
||||
option_t options[] = {
|
||||
{ "F:", &fflag, &fopt }, /* -F filename */
|
||||
{ "T:", &Tflag, &Topt }, /* -T <fd> exec'ed by test: test FD */
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
int stat_loc; /* for waitpid() */
|
||||
|
||||
int npipe_fd;
|
||||
/* file descriptors for a named pipe */
|
||||
#define DEFAULT_FILE "DefaultFileName"
|
||||
char *File1 = DEFAULT_FILE;
|
||||
|
||||
#define DEFAULT_SUBPROG "test_open"
|
||||
char *openck = DEFAULT_SUBPROG; /* support program name to check for open FD */
|
||||
char subprog_path[_POSIX_PATH_MAX]; /* path to exec "openck" with */
|
||||
#define STRSIZE 255
|
||||
#define FIFONAME "FiFo"
|
||||
|
||||
int *testfds[] = {
|
||||
&npipe_fd, 0
|
||||
};
|
||||
|
||||
char *testfdtypes[] = {
|
||||
"named pipe"
|
||||
};
|
||||
|
||||
int test_open(char *arg);
|
||||
int do_exec(char *prog, int fd, char *tcd);
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
int exec_return; /* return from do_exec */
|
||||
int **tcp; /* testcase pointer (pointer to FD) */
|
||||
char **tcd; /* testcase description pointer */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options, and exit if there is an error
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, options, &help)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
if(fflag) /* -F option */
|
||||
File1 = fopt;
|
||||
|
||||
if(Tflag) { /* -T option */
|
||||
exit(test_open(Topt));
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup(av[0]);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for(tcp = testfds, tcd = testfdtypes; *tcp; tcp++, tcd++) {
|
||||
|
||||
TEST(fcntl(**tcp, F_SETFD, FD_CLOEXEC));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "fcntl(%s[%d], F_SETFD, FD_CLOEXEC) Failed, errno=%d : %s",
|
||||
*tcd, **tcp, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/*************************************************************
|
||||
* only perform functional verification if flag set
|
||||
* (-f not given)
|
||||
*************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
|
||||
exec_return = do_exec(subprog_path, **tcp, *tcd);
|
||||
|
||||
switch(exec_return) {
|
||||
case -1:
|
||||
tst_resm(TBROK, "fork failed. Errno %s [%d]",
|
||||
strerror(errno), errno);
|
||||
break;
|
||||
case 1:
|
||||
tst_resm(TBROK, "waitpid return was 0%o", stat_loc);
|
||||
break;
|
||||
case 2:
|
||||
tst_resm(TBROK, "exec failed"); /* errno was in child */
|
||||
break;
|
||||
case 0:
|
||||
tst_resm(TPASS, "%s child exited 0, indicating that the file was closed",
|
||||
*tcd);
|
||||
break;
|
||||
default:
|
||||
tst_resm(TFAIL, "%s child exited non-zero, %d", *tcd,
|
||||
exec_return);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup(char *path)
|
||||
{
|
||||
search_path(path, subprog_path, X_OK, 1);
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* create a temporary directory and go to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* set up a named pipe (write side gets CLOSE-ON-EXEC) */
|
||||
if(mkfifo(FIFONAME, 0666) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "mkfifo of named pipe %s failed errno %d (%s)\n", FIFONAME, errno, strerror(errno));
|
||||
}
|
||||
|
||||
if((npipe_fd=open(FIFONAME, O_RDWR, 0666)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "Open of named pipe %s failed errno %d (%s)\n", File1, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close everything */
|
||||
close(npipe_fd);
|
||||
|
||||
/* remove temporary directory and all files in it. */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
/***************************************************************************
|
||||
* issue a help message
|
||||
***************************************************************************/
|
||||
void
|
||||
help()
|
||||
{
|
||||
printf("-T fd : If this option is given, the program runs as 'test_open'\n");
|
||||
printf(" testing <fd> to see if it is open or not and exiting accordingly\n");
|
||||
printf("-F name : File to open. Must be an absolute path,\n");
|
||||
printf(" and the file must be writable\n");
|
||||
printf("-n program: path to the 'test_open' program\n");
|
||||
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Perform an exec, then wait for the child to terminate.
|
||||
* The child's termination status determines the success of the test
|
||||
*
|
||||
* Return codes:
|
||||
* -1 BROK fork failed
|
||||
* 1 BROK waitpid returned != exit status
|
||||
* <else> ???? exit code from child:
|
||||
* 2 BROK exec failed
|
||||
* 0 PASS fd was properly closed
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
do_exec(char *prog, int fd, char *tcd)
|
||||
{
|
||||
int pid;
|
||||
char pidname[STRSIZE];
|
||||
#ifdef DEBUG
|
||||
int rc, status; /* for the fcntl */
|
||||
#endif
|
||||
|
||||
/* set up arguments to exec'ed child */
|
||||
sprintf(pidname, "%d", fd);
|
||||
|
||||
#ifdef DEBUG
|
||||
rc = fcntl(fd, F_GETFD, &status);
|
||||
printf("%s: fd = %d rc = %d status= %d, errno= %d\n", tcd, fd, rc, status, errno);
|
||||
#endif
|
||||
|
||||
switch(pid=fork()) {
|
||||
case -1:
|
||||
return(-1);
|
||||
case 0: /* child */
|
||||
execlp(prog, openck, "-T", pidname, 0);
|
||||
|
||||
/* the ONLY reason to do this is to get the errno printed out */
|
||||
fprintf(stderr, "exec(%s, %s, -T, %s) failed. Errno %s [%d]\n",
|
||||
prog, openck, pidname, strerror(errno), errno);
|
||||
exit(2);
|
||||
default: /* parent */
|
||||
waitpid(pid, &stat_loc, 0);
|
||||
if(WIFEXITED(stat_loc)) {
|
||||
return(WEXITSTATUS(stat_loc));
|
||||
} else {
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* PROGRAM TITLE : Test if a named file descriptor is open
|
||||
* This function is called when fcntcs07 is called with the -T option.
|
||||
* It tests if a file descriptor is open and exits accordingly.
|
||||
*/
|
||||
int
|
||||
test_open(char *arg)
|
||||
{
|
||||
int fd, rc;
|
||||
int status;
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
fd = atoi(arg);
|
||||
|
||||
rc = fcntl(fd, F_GETFD, &status);
|
||||
|
||||
#ifdef DEBUG_T
|
||||
printf("%s: fd = %d rc = %d status= %d, errno= %d\n", openck, fd, rc,
|
||||
status, errno);
|
||||
#endif
|
||||
|
||||
if(rc == -1 && errno == EBADF) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(rc != -1)
|
||||
exit(3);
|
||||
|
||||
exit(errno);
|
||||
return -1; /* To remove compiler warning on IRIX */
|
||||
}
|
||||
250
winsup/testsuite/winsup.api/ltp/fcntl08.c
Normal file
250
winsup/testsuite/winsup.api/ltp/fcntl08.c
Normal file
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fcntl08
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fcntl(2) using F_SETFL argument.
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fcntl(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fcntl(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fcntl(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* close file
|
||||
* remove temp directory
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
#ifndef O_NDELAY
|
||||
#define O_NDELAY 0
|
||||
#endif
|
||||
|
||||
char *TCID="fcntl08"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
char fname[255];
|
||||
int arg, fd;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call fcntl(2) with F_SETFL argument on fname
|
||||
*/
|
||||
TEST(fcntl(fd, F_SETFL, arg));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
tst_resm(TFAIL, "fcntl(%s, F_SETFL, %d) Failed, errno=%d : %s",
|
||||
fname, arg, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "fcntl(%s, F_SETFL, %d) returned %d",
|
||||
fname, arg, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* set the flags to be used */
|
||||
#ifdef CRAY
|
||||
arg = (O_NDELAY | O_APPEND | O_RAW | O_NONBLOCK);
|
||||
#else
|
||||
arg = (O_NDELAY | O_APPEND | O_NONBLOCK);
|
||||
#endif /* ! CRAY */
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the file we have open */
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
|
||||
} /* End cleanup() */
|
||||
272
winsup/testsuite/winsup.api/ltp/fcntl09.c
Normal file
272
winsup/testsuite/winsup.api/ltp/fcntl09.c
Normal file
@ -0,0 +1,272 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fcntl09
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fcntl(2) using F_SETLK argument.
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 2
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fcntl(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fcntl(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fcntl(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fcntl09"; /* Test program identifier. */
|
||||
int TST_TOTAL=2; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
struct flock flocks;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
flocks.l_type = F_RDLCK | F_WRLCK;
|
||||
/*
|
||||
* Call fcntl(2) with F_SETLK argument on fname
|
||||
*/
|
||||
TEST(fcntl(fd, F_SETLK, &flocks));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL,
|
||||
"fcntl(%s, F_SETLK, &flocks) flocks.l_type = F_RDLCK | F_WRLCK Failed, errno=%d : %s",
|
||||
fname, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS,
|
||||
"fcntl(%s, F_SETLK, &flocks) flocks.l_type = F_RDLCK | F_WRLCK returned %d",
|
||||
fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
flocks.l_type = F_UNLCK;
|
||||
/*
|
||||
* Call fcntl(2) with F_SETLK argument on fname
|
||||
*/
|
||||
TEST(fcntl(fd, F_SETLK, &flocks));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL,
|
||||
"fcntl(%s, F_SETLK, &flocks) flocks.l_type = F_UNLCK Failed, errno=%d : %s",
|
||||
fname, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS,
|
||||
"fcntl(%s, F_SETLK, &flocks) flocks.l_type = F_UNLCK returned %d",
|
||||
fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"./file_%d",getpid());
|
||||
if (creat(fname, 02644) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "creat(%s, 02644) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
} else if (close(fd) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
} else if ((fd = open(fname,O_RDWR,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "open(%s, O_RDWR,0700) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
flocks.l_whence=1;
|
||||
flocks.l_start=0;
|
||||
flocks.l_len=0;
|
||||
flocks.l_pid=getpid();
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
} else if (unlink(fname) == -1) {
|
||||
tst_resm(TWARN, "unlink(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
|
||||
}
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
278
winsup/testsuite/winsup.api/ltp/fcntl10.c
Normal file
278
winsup/testsuite/winsup.api/ltp/fcntl10.c
Normal file
@ -0,0 +1,278 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fcntl10
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fcntl(2) using F_SETLKW argument.
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 2
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fcntl(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fcntl(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fcntl(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fcntl10"; /* Test program identifier. */
|
||||
int TST_TOTAL=2; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
struct flock flocks;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
flocks.l_type = F_RDLCK | F_WRLCK;
|
||||
/*
|
||||
* Call fcntl(2) with F_SETLKW flocks.l_type = F_UNLCK argument on fname
|
||||
*/
|
||||
TEST(fcntl(fd, F_SETLKW, &flocks));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL,
|
||||
"fcntl(%s, F_SETLKW, &flocks) flocks.l_type = F_RDLCK | F_WRLCK Failed, errno=%d : %s",
|
||||
fname, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS,
|
||||
"fcntl(%s, F_SETLKW, &flocks) flocks.l_type = F_RDLCK | F_WRLCK returned %d",
|
||||
fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
flocks.l_type = F_UNLCK;
|
||||
/*
|
||||
* Call fcntl(2) with F_SETLKW flocks.l_type = F_UNLCK argument on fname
|
||||
*/
|
||||
TEST(fcntl(fd, F_SETLKW, &flocks));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL,
|
||||
"fcntl(%s, F_SETLKW, &flocks) flocks.l_type = F_UNLCK Failed, errno=%d : %s",
|
||||
fname, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS,
|
||||
"fcntl(%s, F_SETLKW, &flocks) flocks.l_type = F_UNLCK returned %d",
|
||||
fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = creat(fname, 02644)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "creat(%s, 02644) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
} else if (close(fd) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
} else if ((fd = open(fname,O_RDWR,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "open(%s, O_RDWR,0700) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* set needed fields in the flocks structure */
|
||||
flocks.l_whence=1;
|
||||
flocks.l_start=0;
|
||||
flocks.l_len=0;
|
||||
flocks.l_pid=getpid();
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
317
winsup/testsuite/winsup.api/ltp/fork01.c
Normal file
317
winsup/testsuite/winsup.api/ltp/fork01.c
Normal file
@ -0,0 +1,317 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fork01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fork(2)
|
||||
*
|
||||
* PARENT DOCUMENT : frktds02
|
||||
*
|
||||
* TEST CASE TOTAL : 2
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Kathy Olmsted
|
||||
*
|
||||
* CO-PILOT : Steve Shaw
|
||||
*
|
||||
* DATE STARTED : 06/17/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fork returns without error
|
||||
* 2.) fork returns the pid of the child
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* fork()
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
* CHILD:
|
||||
* determine PID
|
||||
* write to PID to a file and close the file
|
||||
* exit
|
||||
* PARENT:
|
||||
* wait for child to exit
|
||||
* read child PID from file
|
||||
* compare child PID to fork() return code and report
|
||||
* results
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
#define KIDEXIT 42
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
#define LINE_SZ 20 /* size of the line written/read to the file */
|
||||
#define FILENAME "childpid"
|
||||
|
||||
|
||||
|
||||
char *TCID="fork01"; /* Test program identifier. */
|
||||
int TST_TOTAL=2; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
/***************************************************************
|
||||
* child_pid - the child side of the test
|
||||
* determine the PID and write to a file
|
||||
***************************************************************/
|
||||
void child_pid()
|
||||
{
|
||||
|
||||
int fildes;
|
||||
char tmp_line[LINE_SZ];
|
||||
|
||||
fildes = creat(FILENAME,0700);
|
||||
sprintf(tmp_line,"%d\n",getpid());
|
||||
write(fildes,tmp_line,LINE_SZ);
|
||||
close(fildes);
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* parent_pid - the parent side of the test
|
||||
* read the value determined by the child
|
||||
* compare and report results
|
||||
***************************************************************/
|
||||
void parent_pid()
|
||||
{
|
||||
|
||||
int fildes;
|
||||
char tmp_line[LINE_SZ];
|
||||
pid_t child_id;
|
||||
|
||||
if ((fildes = open(FILENAME,O_RDWR)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"parent open failed. errno: %d (%s)\n",
|
||||
errno, strerror(errno));
|
||||
}
|
||||
else {
|
||||
if (read(fildes,tmp_line,LINE_SZ) == 0) {
|
||||
tst_brkm(TBROK,cleanup, "fork(): parent failed to read PID from file errno: %d (%s)",
|
||||
errno, strerror(errno));
|
||||
}
|
||||
else {
|
||||
child_id = atoi(tmp_line);
|
||||
if (TEST_RETURN != child_id) {
|
||||
tst_resm(TFAIL,"child reported a pid of %d. parent received %d from fork()",
|
||||
child_id,TEST_RETURN);
|
||||
} else {
|
||||
tst_resm(TPASS,"child pid and fork() return agree: %d",child_id);
|
||||
}
|
||||
}
|
||||
close(fildes);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* main() - performs tests
|
||||
*
|
||||
***************************************************************/
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
int fails;
|
||||
int kid_status, wait_status;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
fails = 0;
|
||||
|
||||
/*
|
||||
* Call fork(2)
|
||||
*/
|
||||
TEST(fork());
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
tst_resm(TFAIL, "fork() Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
tst_resm(TBROK,"unable to continue");
|
||||
}
|
||||
}
|
||||
if (TEST_RETURN == 0) {
|
||||
/* child */
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
child_pid();
|
||||
}
|
||||
exit(KIDEXIT);
|
||||
} else {
|
||||
/* parent */
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
tst_resm(TPASS, "fork() returned %d", TEST_RETURN);
|
||||
}
|
||||
/* wait for the child to complete */
|
||||
wait_status = wait(&kid_status);
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if (wait_status == TEST_RETURN) {
|
||||
if (kid_status != KIDEXIT << 8) {
|
||||
tst_resm(TBROK,
|
||||
"incorrect child status returned on wait(): %d",
|
||||
kid_status);
|
||||
fails++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TBROK,
|
||||
"wait() for child status failed with %d errno: %d : %s",
|
||||
wait_status,errno,strerror(errno));
|
||||
fails++;
|
||||
}
|
||||
if (fails == 0 ) {
|
||||
/* verification tests */
|
||||
parent_pid();
|
||||
}
|
||||
} /* STD_FUNCTIONAL_TEST */
|
||||
} /* TEST_RETURN */
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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_rmdir();
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
405
winsup/testsuite/winsup.api/ltp/fork04.c
Normal file
405
winsup/testsuite/winsup.api/ltp/fork04.c
Normal file
@ -0,0 +1,405 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fork04
|
||||
*
|
||||
* TEST TITLE : Child inheritance of Environment Variables after fork()
|
||||
*
|
||||
* PARENT DOCUMENT : frktds01
|
||||
*
|
||||
* TEST CASE TOTAL : 3
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Kathy Olmsted
|
||||
*
|
||||
* CO-PILOT : Steve Shaw
|
||||
*
|
||||
* DATE STARTED : 06/17/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
* Test these environment variables correctly inherited by child:
|
||||
* 1. TERM
|
||||
* 2. NoTSetzWq
|
||||
* 3. TESTPROG
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Make and change to a temporary directory.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
* Add TESTPROG variable to the environment
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* fork()
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno
|
||||
* CHILD:
|
||||
* open a temp file
|
||||
* Determine environment values and write to file
|
||||
* close file containing test values.
|
||||
* exit.
|
||||
* PARENT:
|
||||
* Wait for child to exit.
|
||||
* Verify exit status
|
||||
* Open file containing test values.
|
||||
* For each test case:
|
||||
* Read the value from the file.
|
||||
* Determine and report PASS/FAIL result.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
* Remove the temporary directory and exit.
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include <signal.h> /*Includes signal information. */
|
||||
#include <errno.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
char *TCID="fork04"; /* Test program identifier. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
|
||||
|
||||
#define KIDEXIT 42 /* Known value for child exit status */
|
||||
#define MAX_LINE_LENGTH 256
|
||||
#define OUTPUT_FILE "env.out"
|
||||
#define ENV_NOT_SET "getenv() does not find variable set"
|
||||
|
||||
/* list of environment variables to test */
|
||||
char *environ_list[] = {"TERM","NoTSetzWq","TESTPROG"};
|
||||
#define NUMBER_OF_ENVIRON sizeof(environ_list)/sizeof(char *)
|
||||
int TST_TOTAL=NUMBER_OF_ENVIRON; /* Total number of test cases. */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove the temporary directory and exit with
|
||||
return code appropriate for results */
|
||||
tst_rmdir();
|
||||
tst_exit();
|
||||
|
||||
} /* End cleanup() */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make and change to a temporary directory */
|
||||
tst_tmpdir();
|
||||
|
||||
/* add a variable to the environment */
|
||||
putenv("TESTPROG=FRKTCS04");
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* child_environment - the child side of the environment tests
|
||||
* determine values for the variables and write to a file
|
||||
***************************************************************/
|
||||
void child_environment()
|
||||
{
|
||||
|
||||
int fildes;
|
||||
int index;
|
||||
char msg[MAX_LINE_LENGTH];
|
||||
char *var;
|
||||
|
||||
fildes = creat(OUTPUT_FILE,0700);
|
||||
|
||||
|
||||
for (index=0;index<NUMBER_OF_ENVIRON;index++) {
|
||||
memset(msg, 0, MAX_LINE_LENGTH);
|
||||
|
||||
if ( (var=getenv(environ_list[index])) == NULL )
|
||||
(void)sprintf(msg,"%s:%s",environ_list[index], ENV_NOT_SET);
|
||||
else
|
||||
(void)sprintf(msg,"%s:%s",environ_list[index], var);
|
||||
|
||||
write(fildes,msg,sizeof(msg)); /* includes extra null chars */
|
||||
}
|
||||
|
||||
close(fildes);
|
||||
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Compare parent env string to child's string.
|
||||
* Each string is in the format: <env var>:<value>
|
||||
*
|
||||
***********************************************************************/
|
||||
int
|
||||
cmp_env_strings(char *pstring, char *cstring)
|
||||
{
|
||||
char *penv, *cenv, *pvalue, *cvalue;
|
||||
|
||||
/*
|
||||
* Break pstring into env and value
|
||||
*/
|
||||
penv=pstring;
|
||||
if ( (pvalue=strchr(pstring, ':')) == NULL ) {
|
||||
tst_resm(TBROK,
|
||||
"internal error - parent's env string not in correct format:'%s'",
|
||||
pstring);
|
||||
return -1;
|
||||
} else {
|
||||
*pvalue='\0';
|
||||
pvalue++;
|
||||
if ( *pvalue == '\0' ) {
|
||||
tst_resm(TBROK, "internal error - missing parent's env value");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Break cstring into env and value
|
||||
*/
|
||||
cenv=cstring;
|
||||
if ( (cvalue=strchr(cstring, ':')) == NULL ) {
|
||||
tst_resm(TBROK,
|
||||
"internal error - parent's env string not in correct format:'%s'",
|
||||
cstring);
|
||||
return -1;
|
||||
} else {
|
||||
*cvalue='\0';
|
||||
cvalue++;
|
||||
if ( *cvalue == '\0' ) {
|
||||
tst_resm(TBROK, "internal error - missing child's env value");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( strcmp(penv, cenv) != 0 ) {
|
||||
tst_resm(TBROK, "internal error - parent(%s) != child (%s) env",
|
||||
penv, cenv);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( strcmp(pvalue, cvalue) != 0 ) {
|
||||
tst_resm(TFAIL, "Env var %s changed after fork(), parent's %s, child's %s",
|
||||
penv, pvalue, cvalue);
|
||||
} else {
|
||||
tst_resm(TPASS, "Env var %s unchanged after fork(): %s",
|
||||
penv, cvalue);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* parent_environment - the parent side of the environment tests
|
||||
* determine values for the variables
|
||||
* read the values determined by the child
|
||||
* compare values
|
||||
***************************************************************/
|
||||
void parent_environment()
|
||||
{
|
||||
|
||||
int fildes;
|
||||
char tmp_line[MAX_LINE_LENGTH];
|
||||
char parent_value[MAX_LINE_LENGTH];
|
||||
int index;
|
||||
int ret;
|
||||
char *var;
|
||||
|
||||
if ((fildes = open(OUTPUT_FILE,O_RDWR)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"fork() test. Parent open of temporary file failed. errno %d (%s)\n",
|
||||
errno, strerror(errno));
|
||||
}
|
||||
for (index=0;index<NUMBER_OF_ENVIRON;index++)
|
||||
{
|
||||
if ((ret=read(fildes,tmp_line,MAX_LINE_LENGTH)) == 0) {
|
||||
tst_resm(TBROK,"fork() test. parent_environment: failed to read from file with %d (%s)",
|
||||
errno,strerror(errno));
|
||||
}
|
||||
else {
|
||||
|
||||
if ( (var=getenv(environ_list[index])) == NULL )
|
||||
sprintf(parent_value,"%s:%s", environ_list[index], ENV_NOT_SET);
|
||||
else
|
||||
sprintf(parent_value,"%s:%s", environ_list[index], var);
|
||||
|
||||
cmp_env_strings(parent_value, tmp_line);
|
||||
|
||||
}
|
||||
}
|
||||
close(fildes);
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* main() - performs tests
|
||||
*
|
||||
***************************************************************/
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
int kid_status; /* status returned from child */
|
||||
int wait_status; /* status of wait system call in parent */
|
||||
int fails; /* indicates whether to continue with tests */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count and fail indicator in case we are looping. */
|
||||
Tst_count=0;
|
||||
fails = 0;
|
||||
|
||||
/* make the call to fork */
|
||||
TEST(fork());
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
/* fork failed */
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
tst_brkm(TFAIL, cleanup, "fork() failed with %d (%s)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
}
|
||||
else if (TEST_RETURN == 0) {
|
||||
/* child */
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* determine environment variables */
|
||||
child_environment();
|
||||
}
|
||||
/* exit with known value */
|
||||
exit(KIDEXIT);
|
||||
} else {
|
||||
/* parent of successful fork */
|
||||
/* wait for the child to complete */
|
||||
wait_status = wait(&kid_status);
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* validate the child exit status */
|
||||
if (wait_status == TEST_RETURN) {
|
||||
if (kid_status != KIDEXIT << 8) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"fork(): Incorrect child status returned on wait(): %d",
|
||||
kid_status);
|
||||
fails++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"fork(): wait() for child status failed with %d errno: %d : %s",
|
||||
wait_status,errno,strerror(errno));
|
||||
fails++;
|
||||
}
|
||||
|
||||
if (fails == 0 ) {
|
||||
/* verification tests */
|
||||
parent_environment();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
257
winsup/testsuite/winsup.api/ltp/fpathconf01.c
Normal file
257
winsup/testsuite/winsup.api/ltp/fpathconf01.c
Normal file
@ -0,0 +1,257 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fpathconf01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fpathconf(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 7
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fpathconf(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fpathconf(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fpathconf(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fpathconf01"; /* Test program identifier. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
#define FILENAME "fpafile01"
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int i;
|
||||
|
||||
struct pathconf_args
|
||||
{
|
||||
char *define_tag;
|
||||
int value;
|
||||
int defined; /* Some of these are undefined on regular files.
|
||||
* Cancer does a slightly better job with these already,
|
||||
* so this is all I'll do to this test. 11/19/98 roehrich
|
||||
*/
|
||||
} args[] = {
|
||||
{"_PC_MAX_CANON", _PC_MAX_CANON, 0},
|
||||
{"_PC_MAX_INPUT", _PC_MAX_INPUT, 0},
|
||||
{"_PC_VDISABLE", _PC_VDISABLE, 0},
|
||||
{"_PC_LINK_MAX", _PC_LINK_MAX, 1},
|
||||
{"_PC_NAME_MAX", _PC_NAME_MAX, 1},
|
||||
{"_PC_PATH_MAX", _PC_PATH_MAX, 1},
|
||||
{"_PC_PIPE_BUF", _PC_PIPE_BUF, 0}
|
||||
};
|
||||
|
||||
int TST_TOTAL=((sizeof(args)/sizeof(args[0])));
|
||||
int fd; /* temp file for fpathconf */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for (i=0; i<TST_TOTAL; i++) {
|
||||
/*
|
||||
* Call fpathconf(2) with one of the valid arguments in the args array
|
||||
*/
|
||||
TEST(fpathconf(fd,args[i].value));
|
||||
|
||||
/* check return code -- if the return value is defined */
|
||||
if ( (TEST_RETURN == -1) && args[i].defined ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "fpathconf(fd, %s) Failed, errno=%d : %s", args[i].define_tag,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "fpathconf(fd, %s) returned %d", args[i].define_tag, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
} /* End for i */
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
tst_tmpdir();
|
||||
|
||||
if ( (fd=open(FILENAME, O_RDWR|O_CREAT, 0700)) == -1 )
|
||||
tst_brkm(TBROK, cleanup, "Unable to open temp file %s!", FILENAME);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
close(fd);
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_rmdir();
|
||||
tst_exit();
|
||||
|
||||
} /* End cleanup() */
|
||||
239
winsup/testsuite/winsup.api/ltp/fstat01.c
Normal file
239
winsup/testsuite/winsup.api/ltp/fstat01.c
Normal file
@ -0,0 +1,239 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fstat01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fstat(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fstat(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fstat(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fstat(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fstat01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
struct stat statter;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call fstat(2)
|
||||
*/
|
||||
TEST(fstat(fd, &statter));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "fstat(%s, &statter) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "fstat(%s, &statter) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
248
winsup/testsuite/winsup.api/ltp/fsync01.c
Normal file
248
winsup/testsuite/winsup.api/ltp/fsync01.c
Normal file
@ -0,0 +1,248 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : fsync01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for fsync(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) fsync(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the fsync(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* fsync(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/statfs.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="fsync01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
char *buf = "davef";
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/* write sone data to get fsync'd out */
|
||||
if (write(fd, &buf, strlen(buf)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"write(%s, &buf, strlen(buf)) Failed, errno=%d : %s",
|
||||
fname, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
/*
|
||||
* Call fsync(2)
|
||||
*/
|
||||
TEST(fsync(fd));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "fsync(%s) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "fsync(%s) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the file we have open */
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
226
winsup/testsuite/winsup.api/ltp/getegid01.c
Normal file
226
winsup/testsuite/winsup.api/ltp/getegid01.c
Normal file
@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : getegid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for getegid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) getegid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the getegid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* getegid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="getegid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0}; /* must be a 0 terminated list */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* Get effective group id.
|
||||
*/
|
||||
;
|
||||
|
||||
/* Call getegid(2) */
|
||||
TEST(getegid( ));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN < 0 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "getegid - Get effective group id. failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
continue; /* next loop for MTKERNEL */
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "getegid - Get effective group id. returned %d", TEST_RETURN);
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
|
||||
|
||||
226
winsup/testsuite/winsup.api/ltp/geteuid01.c
Normal file
226
winsup/testsuite/winsup.api/ltp/geteuid01.c
Normal file
@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : geteuid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for geteuid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) geteuid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the geteuid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* geteuid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="geteuid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0}; /* must be a 0 terminated list */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* Get effective user id.
|
||||
*/
|
||||
;
|
||||
|
||||
/* Call geteuid(2) */
|
||||
TEST(geteuid( ));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN < 0 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "geteuid - Get effective user id. failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
continue; /* next loop for MTKERNEL */
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "geteuid - Get effective user id. returned %d", TEST_RETURN);
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
|
||||
|
||||
219
winsup/testsuite/winsup.api/ltp/getgid01.c
Normal file
219
winsup/testsuite/winsup.api/ltp/getgid01.c
Normal file
@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : getgid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for getgid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) getgid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the getgid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* getgid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="getgid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call getgid(2)
|
||||
*/
|
||||
TEST(getgid());
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "getgid() Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "getgid() returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
315
winsup/testsuite/winsup.api/ltp/getgroups01.c
Normal file
315
winsup/testsuite/winsup.api/ltp/getgroups01.c
Normal file
@ -0,0 +1,315 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/***********************************************************************
|
||||
TEST IDENTIFIER: getgroups01 : Getgroups system call critical test
|
||||
|
||||
PARENT DOCUMENT: ggrtds01: Getgroups system call test design spec
|
||||
|
||||
AUTHOR: Barrie Kletscher
|
||||
Rewrote : 11-92 by Richard Logan
|
||||
|
||||
CO-PILOT: Dave Baumgartner
|
||||
|
||||
TEST ITEMS:
|
||||
1. Check to see if getgroups(-1, gidset) fails and sets errno to EINVAL
|
||||
2. Check to see if getgroups(0, gidset) does not return -1 and gidset is
|
||||
not modified.
|
||||
3. Check to see if getgroups(x, gigset) fails and sets errno to EINVAL,
|
||||
where x is one less then what is returned by getgroups(0, gidset).
|
||||
4. Check to see if getgroups() succeeds and gidset contains
|
||||
group id returned from getgid().
|
||||
|
||||
INPUT SPECIFICATIONS:
|
||||
NONE
|
||||
|
||||
OUTPUT SPECIFICATIONS:
|
||||
Standard tst_res output format
|
||||
|
||||
ENVIRONMENTAL NEEDS:
|
||||
NONE.
|
||||
|
||||
SPECIAL PROCEDURAL REQUIREMENTS:
|
||||
None
|
||||
|
||||
INTERCASE DEPENDENCIES:
|
||||
Test case #3 depends on test case #2.
|
||||
|
||||
DETAILED DESCRIPTION:
|
||||
Set up the signal handling capabilities.
|
||||
execute tests
|
||||
exit
|
||||
|
||||
BUGS:
|
||||
None known.
|
||||
|
||||
************************************************************/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/param.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
char *TCID="getgroups01"; /* Test program identifier. */
|
||||
int TST_TOTAL=4; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
/***********************************************************************
|
||||
* MAIN
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *ptr; /* message returned from parse_opts */
|
||||
|
||||
int i, /* counter */
|
||||
group, /* return value from Getgid() call */
|
||||
entries; /* number of group entries */
|
||||
|
||||
gid_t gidset[NGROUPS]; /* storage for all group ids */
|
||||
gid_t cmpset[NGROUPS];
|
||||
int ret;
|
||||
int ret2;
|
||||
int errors = 0;
|
||||
char msg[500];
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options, and exit if there is an error
|
||||
***************************************************************/
|
||||
if ( (ptr=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", ptr);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* Check to see if getgroups() fails on erraneous condition.
|
||||
*/
|
||||
TEST( getgroups(-1,gidset) );
|
||||
|
||||
if((ret=TEST_RETURN) != -1) {
|
||||
sprintf(msg,
|
||||
"getgroups(-1,gidset) returned %d, expected -1 and errno = EINVAL",
|
||||
ret);
|
||||
tst_resm(TFAIL,msg);
|
||||
errors++;
|
||||
}
|
||||
else if ( STD_FUNCTIONAL_TEST ) {
|
||||
if(errno != EINVAL) {
|
||||
sprintf(msg,
|
||||
"getgroups(-1,gidset) returned %d, errno = %d, expected errno %d (EINVAL)",
|
||||
ret, errno, EINVAL);
|
||||
tst_resm(TFAIL,msg);
|
||||
errors++;
|
||||
}
|
||||
else {
|
||||
sprintf(msg,
|
||||
"getgroups(-1,gidset) returned %d and error = %d (EINVAL) as expected",
|
||||
ret, errno);
|
||||
tst_resm(TPASS, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that if ngrps is zero that the number of groups is return and
|
||||
* the the gidset array is not modified.
|
||||
* This is a POSIX special case.
|
||||
*/
|
||||
|
||||
memset(gidset, 052, NGROUPS);
|
||||
memset(cmpset, 052, NGROUPS);
|
||||
|
||||
TEST( getgroups(0,gidset) );
|
||||
if((ret=TEST_RETURN) < 0) {
|
||||
sprintf(msg,
|
||||
"getgroups(0,gidset) returned %d with errno = %d, expected num gids with no change to gidset",
|
||||
ret, errno);
|
||||
tst_resm(TFAIL,msg);
|
||||
errors++;
|
||||
}
|
||||
else if ( STD_FUNCTIONAL_TEST ) {
|
||||
/*
|
||||
* check that gidset was unchanged
|
||||
*/
|
||||
if ( memcmp(cmpset, gidset, NGROUPS) != 0 ) {
|
||||
sprintf(msg,
|
||||
"getgroups(0,gidset) returned %d, the gidset array was modified",
|
||||
ret);
|
||||
tst_resm(TFAIL,msg);
|
||||
errors++;
|
||||
}
|
||||
else {
|
||||
sprintf(msg,
|
||||
"getgroups(0,gidset) returned %d, the gidset array not was modified",
|
||||
ret);
|
||||
tst_resm(TPASS, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see that is -1 is returned and errno is set to EINVAL when
|
||||
* ngroups is not big enough to hold all groups.
|
||||
*/
|
||||
|
||||
if ( ret <= 1 ) {
|
||||
sprintf(msg, "getgroups(0,gidset) returned %d, Unable to test that\nusing ngrps >=1 but less than number of grps", ret);
|
||||
tst_resm(TCONF, msg);
|
||||
errors++;
|
||||
}
|
||||
else {
|
||||
TEST( getgroups(ret-1, gidset) );
|
||||
if ((ret2 = TEST_RETURN) == -1 ) {
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( errno != EINVAL ) {
|
||||
sprintf(msg,
|
||||
"getgroups(%d, gidset) returned -1, but not errno %d (EINVAL) but %d",
|
||||
ret-1, EINVAL, errno);
|
||||
tst_resm(TFAIL, msg);
|
||||
errors++;
|
||||
}
|
||||
else {
|
||||
sprintf(msg,
|
||||
"getgroups(%d, gidset) returned -1, and errno %d (EINVAL) when %d grps",
|
||||
ret-1, errno, ret);
|
||||
tst_resm(TPASS, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
sprintf(msg,
|
||||
"getgroups(%d, gidset) returned %d, expected -1 and errno EINVAL.",
|
||||
ret-1, ret2);
|
||||
tst_resm(TFAIL, msg);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if getgroups() succeeds and contains getgid's gid.
|
||||
*/
|
||||
|
||||
TEST( getgroups(NGROUPS,gidset) );
|
||||
if((entries = TEST_RETURN) == -1) {
|
||||
sprintf(msg, "getgroups(NGROUPS,gidset) returned -1 and errno = %d", errno);
|
||||
tst_resm(TFAIL, msg);
|
||||
errors++;
|
||||
}
|
||||
else if ( STD_FUNCTIONAL_TEST ) {
|
||||
|
||||
/*
|
||||
* Check to see if getgroups() contains getgid().
|
||||
*/
|
||||
|
||||
group = getgid();
|
||||
|
||||
for(i = 0; i < entries; i++)
|
||||
{
|
||||
if(gidset[i] == group)
|
||||
{
|
||||
sprintf(msg,
|
||||
"getgroups(NGROUPS,gidset) ret %d contains gid %d (from getgid)",
|
||||
entries, group);
|
||||
tst_resm(TPASS, msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( i == entries ) {
|
||||
sprintf(msg,
|
||||
"getgroups(NGROUPS,gidset) ret %d, does not contain gid %d (from getgid)",
|
||||
entries, group);
|
||||
tst_resm(TFAIL,msg);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* end main() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
|
||||
226
winsup/testsuite/winsup.api/ltp/getgroups02.c
Normal file
226
winsup/testsuite/winsup.api/ltp/getgroups02.c
Normal file
@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : getgroups02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for getgroups(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) getgroups(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the getgroups(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* getgroups(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="getgroups02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
/* define array size for gids */
|
||||
#define GID_ARRAY_SIZE 100
|
||||
|
||||
gid_t gidset[GID_ARRAY_SIZE]; /* array of gids */
|
||||
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call getgroups(2)
|
||||
*/
|
||||
TEST(getgroups(GID_ARRAY_SIZE, gidset));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "getgroups() Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "getgroups() returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
224
winsup/testsuite/winsup.api/ltp/gethostid01.c
Normal file
224
winsup/testsuite/winsup.api/ltp/gethostid01.c
Normal file
@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : gethostid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for gethostid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) gethostid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the gethostid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* gethostid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="gethostid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0}; /* must be a 0 terminated list */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* Get host name
|
||||
*/
|
||||
;
|
||||
|
||||
/* Call gethostid(2) */
|
||||
TEST(gethostid( ));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "gethostid - Get host name failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
continue; /* next loop for MTKERNEL */
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "gethostid - Get host name returned %d", TEST_RETURN);
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
|
||||
|
||||
226
winsup/testsuite/winsup.api/ltp/gethostname01.c
Normal file
226
winsup/testsuite/winsup.api/ltp/gethostname01.c
Normal file
@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : gethostname01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for gethostname(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) gethostname(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the gethostname(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* gethostname(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="gethostname01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0}; /* must be a 0 terminated list */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
char hname[100]; /* host name */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* Get host name
|
||||
*/
|
||||
;
|
||||
|
||||
/* Call gethostname(2) */
|
||||
TEST(gethostname(hname, sizeof(hname) ));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "gethostname - Get host name failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
continue; /* next loop for MTKERNEL */
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "gethostname - Get host name returned %d", TEST_RETURN);
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
|
||||
|
||||
219
winsup/testsuite/winsup.api/ltp/getpgrp01.c
Normal file
219
winsup/testsuite/winsup.api/ltp/getpgrp01.c
Normal file
@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : getpgrp01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for getpgrp(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) getpgrp(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the getpgrp(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* getpgrp(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="getpgrp01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call getpgrp(2)
|
||||
*/
|
||||
TEST(getpgrp());
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "getpgrp() Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "getpgrp() returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
217
winsup/testsuite/winsup.api/ltp/getpid01.c
Normal file
217
winsup/testsuite/winsup.api/ltp/getpid01.c
Normal file
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : getpid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for getpid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) getpid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the getpid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* getpid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="getpid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call getpid(2)
|
||||
*/
|
||||
TEST(getpid());
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "getpid() Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "getpid() returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
219
winsup/testsuite/winsup.api/ltp/getppid01.c
Normal file
219
winsup/testsuite/winsup.api/ltp/getppid01.c
Normal file
@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : getppid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for getppid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) getppid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the getppid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* getppid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="getppid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call getppid(2)
|
||||
*/
|
||||
TEST(getppid());
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "getppid() Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "getppid() returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
219
winsup/testsuite/winsup.api/ltp/getuid01.c
Normal file
219
winsup/testsuite/winsup.api/ltp/getuid01.c
Normal file
@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : getuid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for getuid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) getuid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the getuid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* getuid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="getuid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call getuid(2)
|
||||
*/
|
||||
TEST(getuid());
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "getuid() Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "getuid() returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
258
winsup/testsuite/winsup.api/ltp/kill09.c
Normal file
258
winsup/testsuite/winsup.api/ltp/kill09.c
Normal file
@ -0,0 +1,258 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : kill09
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for kill(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) kill(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the kill(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* kill(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
void alarm_handler(int sig);
|
||||
|
||||
|
||||
|
||||
|
||||
char *TCID="kill09"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int fork_pid;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
int status;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/* make a child process so we can kill it */
|
||||
/* If we cannot fork => we cannot test kill, so break and exit */
|
||||
if ((fork_pid=fork()) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"fork() Failure. errno=%d : %s",
|
||||
errno, strerror(errno));
|
||||
}
|
||||
|
||||
if (fork_pid == 0) {
|
||||
/* CHILD */
|
||||
/*
|
||||
* Setup alarm signal if we don't get the signal to prevent this process
|
||||
* from hanging around forever.
|
||||
*/
|
||||
signal(SIGALRM, alarm_handler);
|
||||
alarm(20);
|
||||
pause();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* PARENT */
|
||||
/*
|
||||
* Call kill(2)
|
||||
*/
|
||||
TEST(kill(fork_pid, SIGKILL));
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "kill(%d, SIGKILL) Failed, errno=%d : %s", fork_pid,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "kill(%d, SIGKILL) returned %d", fork_pid, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* wait for process to cleanup zombies.
|
||||
*
|
||||
*/
|
||||
waitpid(0, &status, WNOHANG);
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
(void) signal(SIGCHLD, SIG_IGN);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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
|
||||
alarm_handler(int sig)
|
||||
{
|
||||
exit(8);
|
||||
}
|
||||
263
winsup/testsuite/winsup.api/ltp/link02.c
Normal file
263
winsup/testsuite/winsup.api/ltp/link02.c
Normal file
@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : link02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for link(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) link(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the link(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* link(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="link02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char Fname[255], Lname[255];
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
struct stat fbuf, lbuf;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call link(2)
|
||||
*/
|
||||
TEST(link(Fname, Lname));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "link(%s, %s) Failed, errno=%d : %s",
|
||||
Fname, Lname, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
stat(Fname, &fbuf);
|
||||
stat(Lname, &lbuf);
|
||||
if ( fbuf.st_nlink > 1 && lbuf.st_nlink > 1 &&
|
||||
fbuf.st_nlink == lbuf.st_nlink )
|
||||
|
||||
tst_resm(TPASS, "link(%s, %s) returned %d and link cnts match",
|
||||
Fname, Lname, TEST_RETURN);
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"link(%s, %s) returned %d, stat link cnts do not match %d %d",
|
||||
Fname, Lname, TEST_RETURN, fbuf.st_nlink,
|
||||
lbuf.st_nlink);
|
||||
}
|
||||
}
|
||||
if (unlink(Lname) == -1) {
|
||||
tst_resm(TWARN, "unlink(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
int fd;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
strcpy(Fname, "tfile");
|
||||
if ((fd = open(Fname, O_RDWR|O_CREAT, 0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT, 0700) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
} else if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
strcpy(Lname, "lfile");
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
330
winsup/testsuite/winsup.api/ltp/link03.c
Normal file
330
winsup/testsuite/winsup.api/ltp/link03.c
Normal file
@ -0,0 +1,330 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : link03
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : multi links tests
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 2
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 03/31/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) link(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
* -N #links : Use #links links every iteration
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the link(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* link(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void help();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="link03"; /* Test program identifier. */
|
||||
int TST_TOTAL=2; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
extern int Tst_nobuf;
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
#define BASENAME "lkfile"
|
||||
|
||||
char Basename[255];
|
||||
char Fname[255];
|
||||
int Nlinks=0;
|
||||
char *Nlinkarg;
|
||||
|
||||
int Nflag=0;
|
||||
|
||||
|
||||
/* for test specific parse_opts options */
|
||||
option_t options[] = {
|
||||
{ "N:", &Nflag, &Nlinkarg }, /* -N #links */
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
struct stat fbuf, lbuf;
|
||||
int cnt;
|
||||
int nlinks;
|
||||
char lname[255];
|
||||
|
||||
Tst_nobuf=1;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, options, &help)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
if ( Nflag ) {
|
||||
if (sscanf(Nlinkarg, "%i", &Nlinks) != 1 ) {
|
||||
tst_brkm(TBROK, NULL, "--N option arg is not a number");
|
||||
tst_exit();
|
||||
}
|
||||
if ( Nlinks > 1000 ) {
|
||||
tst_resm(TWARN, "--N option arg > 1000 - may get errno:%d (EMLINK)",
|
||||
EMLINK);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
if ( Nlinks )
|
||||
nlinks = Nlinks;
|
||||
else
|
||||
/* min of 10 links and max of a 100 links */
|
||||
nlinks = (lc%90)+10;
|
||||
|
||||
for(cnt=1; cnt < nlinks; cnt++) {
|
||||
|
||||
sprintf(lname, "%s%d", Basename, cnt);
|
||||
/*
|
||||
* Call link(2)
|
||||
*/
|
||||
TEST(link(Fname, lname));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_brkm(TFAIL, cleanup, "link(%s, %s) Failed, errno=%d : %s",
|
||||
Fname, lname, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
stat(Fname, &fbuf);
|
||||
|
||||
for(cnt=1; cnt < nlinks; cnt++) {
|
||||
sprintf(lname, "%s%d", Basename, cnt);
|
||||
|
||||
stat(lname, &lbuf);
|
||||
if ( fbuf.st_nlink <= 1 || lbuf.st_nlink <= 1 ||
|
||||
(fbuf.st_nlink != lbuf.st_nlink) ) {
|
||||
|
||||
tst_resm(TFAIL,
|
||||
"link(%s, %s[1-%d]) ret %d for %d files, stat values do not match %d %d",
|
||||
Fname, Basename, nlinks, TEST_RETURN, nlinks,
|
||||
fbuf.st_nlink, lbuf.st_nlink);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( cnt >= nlinks ) {
|
||||
tst_resm(TPASS,
|
||||
"link(%s, %s[1-%d]) ret %d for %d files, stat linkcounts match %d",
|
||||
Fname, Basename, nlinks, TEST_RETURN, nlinks,
|
||||
fbuf.st_nlink);
|
||||
}
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
|
||||
for(cnt=1; cnt < nlinks; cnt++) {
|
||||
|
||||
sprintf(lname, "%s%d", Basename, cnt);
|
||||
|
||||
if (unlink(lname) == -1) {
|
||||
tst_res(TWARN, "unlink(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* help
|
||||
***************************************************************/
|
||||
void
|
||||
help()
|
||||
{
|
||||
printf(" -N #links : create #links hard links every iteration\n");
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
int fd;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(Fname,"%s_%d", BASENAME, getpid());
|
||||
if ((fd = open(Fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
} else if (close(fd) == -1) {
|
||||
tst_res(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
sprintf(Basename, "%s_%d.", BASENAME, getpid());
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
426
winsup/testsuite/winsup.api/ltp/link04.c
Normal file
426
winsup/testsuite/winsup.api/ltp/link04.c
Normal file
@ -0,0 +1,426 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : link04
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Negative test cases for link(2).
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 14
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 03/30/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1-14.) link(2) returns...(See Test_cases structure below)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
* Standard tst_res output formt.
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the link(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* link(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/param.h> /* for PATH_MAX */
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
extern char *get_high_address();
|
||||
|
||||
char *TCID="link04"; /* Test program identifier. */
|
||||
int TST_TOTAL=14; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int longpath_setup();
|
||||
int no_setup();
|
||||
int filepath_setup();
|
||||
int filepath2_setup();
|
||||
char Longpathname[PATH_MAX+2];
|
||||
char High_address[64];
|
||||
int dir_setup();
|
||||
|
||||
struct test_case_t {
|
||||
char *file1;
|
||||
char *desc1;
|
||||
char *file2;
|
||||
char *desc2;
|
||||
int exp_errno;
|
||||
int (*setupfunc1)();
|
||||
int (*setupfunc2)();
|
||||
} Test_cases[] = {
|
||||
/* This test program should contain test cases where link */
|
||||
/* will fail regardless of who executed it (i.e. joe-user or root) */
|
||||
|
||||
/* first path is invalid */
|
||||
|
||||
{ "nonexistfile", "non-existent file", "nefile", "nefile",
|
||||
ENOENT, no_setup, no_setup},
|
||||
|
||||
{ "", "path is empty string", "nefile", "nefile",
|
||||
ENOENT, no_setup, no_setup},
|
||||
|
||||
{ "neefile/file", "path contains a non-existent file", "nefile", "nefile",
|
||||
ENOENT, no_setup, no_setup },
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
{ "regfile/file", "path contains a regular file", "nefile", "nefile",
|
||||
ENOTDIR, filepath_setup, no_setup },
|
||||
#endif
|
||||
|
||||
{ Longpathname, "pathname too long", "nefile", "nefile",
|
||||
ENAMETOOLONG, longpath_setup, no_setup },
|
||||
|
||||
{ High_address, "address beyond address space", "nefile", "nefile",
|
||||
EFAULT, no_setup, no_setup },
|
||||
|
||||
{ (char *)-1, "negative address", "nefile", "nefile",
|
||||
EFAULT, no_setup, no_setup },
|
||||
|
||||
/* second path is invalid */
|
||||
|
||||
{ "regfile", "regfile", "", "empty string",
|
||||
ENOENT, no_setup, no_setup},
|
||||
|
||||
{ "regfile", "regfile", "neefile/file", "path contains a non-existent file",
|
||||
ENOENT, filepath_setup, no_setup},
|
||||
|
||||
{ "regfile", "regfile", "file/file", "path contains a regular file",
|
||||
ENOENT, filepath_setup, no_setup},
|
||||
|
||||
{ "regfile", "regfile", Longpathname, "pathname too long",
|
||||
ENAMETOOLONG, no_setup, longpath_setup },
|
||||
|
||||
{ "regfile", "regfile", High_address, "address beyond address space",
|
||||
EFAULT, no_setup, no_setup },
|
||||
|
||||
{ "regfile", "regfile", (char *)-1, "negative address",
|
||||
EFAULT, no_setup, no_setup},
|
||||
|
||||
/* two existing files */
|
||||
|
||||
{ "regfile", "regfile", "regfile2", "regfile2",
|
||||
EEXIST, filepath_setup, filepath2_setup },
|
||||
|
||||
{ NULL, NULL, NULL, NULL, 0, no_setup, no_setup }
|
||||
};
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
char *fname1, *fname2;
|
||||
char *desc1, *desc2;
|
||||
int ind;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for (ind=0; Test_cases[ind].desc1 != NULL; ind++ ) {
|
||||
|
||||
fname1 = Test_cases[ind].file1;
|
||||
desc1 = Test_cases[ind].desc1;
|
||||
fname2 = Test_cases[ind].file2;
|
||||
desc2 = Test_cases[ind].desc2;
|
||||
|
||||
if ( fname1 == High_address )
|
||||
fname1 = get_high_address();
|
||||
|
||||
if ( fname2 == High_address )
|
||||
fname2 = get_high_address();
|
||||
|
||||
/*
|
||||
* Call link(2)
|
||||
*/
|
||||
TEST(link(fname1, fname2));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_ERRNO == Test_cases[ind].exp_errno )
|
||||
tst_resm(TPASS, "link(<%s>, <%s>) Failed, errno=%d",
|
||||
desc1, desc2, TEST_ERRNO);
|
||||
else
|
||||
tst_resm(TFAIL,
|
||||
"link(<%s>, <%s>) Failed, errno=%d, expected errno:%d",
|
||||
desc1, desc2, TEST_ERRNO, Test_cases[ind].exp_errno);
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
} else {
|
||||
tst_resm(TFAIL,
|
||||
"link(<%s>, <%s>) returned %d, expected -1, errno:%d",
|
||||
desc1, desc2, TEST_RETURN, Test_cases[ind].exp_errno);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
int ind;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
for (ind=0; Test_cases[ind].desc1 != NULL; ind++ ) {
|
||||
Test_cases[ind].setupfunc1();
|
||||
Test_cases[ind].setupfunc2();
|
||||
}
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
/******************************************************************
|
||||
*
|
||||
******************************************************************/
|
||||
int
|
||||
no_setup()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
*
|
||||
******************************************************************/
|
||||
int
|
||||
longpath_setup()
|
||||
{
|
||||
int ind;
|
||||
|
||||
static int alreadycalled = 0;
|
||||
|
||||
if ( alreadycalled )
|
||||
return 0;
|
||||
alreadycalled++;
|
||||
|
||||
for(ind=0; ind<= PATH_MAX+1; ind++) {
|
||||
Longpathname[ind] = 'a';
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
*
|
||||
******************************************************************/
|
||||
int
|
||||
filepath2_setup()
|
||||
{
|
||||
int fd;
|
||||
static int alreadycalled = 0;
|
||||
|
||||
if ( alreadycalled )
|
||||
return 0;
|
||||
alreadycalled++;
|
||||
|
||||
if ( (fd=creat("regfile2", 0777)) == -1 ) {
|
||||
tst_brkm(TBROK, cleanup, "creat(regfile2, 0777) failed, errno:%d %s",
|
||||
errno, strerror(errno));
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
/******************************************************************
|
||||
*
|
||||
******************************************************************/
|
||||
int
|
||||
filepath_setup()
|
||||
{
|
||||
int fd;
|
||||
static int alreadycalled = 0;
|
||||
|
||||
if ( alreadycalled )
|
||||
return 0;
|
||||
alreadycalled++;
|
||||
|
||||
if ( (fd=creat("regfile", 0777)) == -1 ) {
|
||||
tst_brkm(TBROK, cleanup, "creat(regfile, 0777) failed, errno:%d %s",
|
||||
errno, strerror(errno));
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
*
|
||||
******************************************************************/
|
||||
int
|
||||
dir_setup()
|
||||
{
|
||||
static int alreadycalled = 0;
|
||||
|
||||
if ( alreadycalled )
|
||||
return 0;
|
||||
alreadycalled++;
|
||||
|
||||
if ( mkdir("dir", 0777) == -1 ) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"mkdir(dir, 0700) Failed, errno=%d : %s",
|
||||
errno, strerror(errno));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
351
winsup/testsuite/winsup.api/ltp/link05.c
Normal file
351
winsup/testsuite/winsup.api/ltp/link05.c
Normal file
@ -0,0 +1,351 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : link05
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : multi links (EMLINK) negative test
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 2
|
||||
*
|
||||
* WALL CLOCK TIME : 3
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 03/31/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) link(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the link(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* link(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
void help();
|
||||
|
||||
|
||||
|
||||
char *TCID="link05"; /* Test program identifier. */
|
||||
#ifdef CRAY
|
||||
int TST_TOTAL=2; /* Total number of test cases. */
|
||||
#else
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
#endif
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
#define BASENAME "lkfile"
|
||||
|
||||
char Basename[255];
|
||||
char Fname[255];
|
||||
|
||||
int Nflag=0;
|
||||
char *Noptlinks;
|
||||
|
||||
/* for test specific parse_opts options */
|
||||
option_t options[] = {
|
||||
{ "N:", &Nflag, &Noptlinks }, /* -N option */
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
int nlinks = 1000;
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
struct stat fbuf, lbuf;
|
||||
int cnt;
|
||||
char lname[255];
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, options, &help)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
if ( Nflag ) {
|
||||
if ( sscanf(Noptlinks, "%i", &nlinks) != 1 ) {
|
||||
tst_brkm(TBROK, cleanup, "-N option invalid, must be numeric");
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for(cnt=1; cnt < nlinks; cnt++) {
|
||||
|
||||
sprintf(lname, "%s%d", Basename, cnt);
|
||||
/*
|
||||
* Call link(2)
|
||||
*/
|
||||
TEST(link(Fname, lname));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
tst_resm(TFAIL, "link(%s, %s) Failed, errno=%d : %s",
|
||||
Fname, lname, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
stat(Fname, &fbuf);
|
||||
|
||||
for(cnt=1; cnt < nlinks; cnt++) {
|
||||
sprintf(lname, "%s%d", Basename, cnt);
|
||||
|
||||
stat(lname, &lbuf);
|
||||
if ( fbuf.st_nlink <= 1 || lbuf.st_nlink <= 1 ||
|
||||
(fbuf.st_nlink != lbuf.st_nlink) ) {
|
||||
|
||||
tst_resm(TFAIL,
|
||||
"link(%s, %s[1-%d]) ret %d for %d files, stat values do not match %d %d",
|
||||
Fname, Basename, nlinks, TEST_RETURN, nlinks,
|
||||
fbuf.st_nlink, lbuf.st_nlink);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( cnt >= nlinks ) {
|
||||
tst_resm(TPASS,
|
||||
"link(%s, %s[1-%d]) ret %d for %d files, stat linkcounts match %d",
|
||||
Fname, Basename, nlinks, TEST_RETURN, nlinks,
|
||||
fbuf.st_nlink);
|
||||
}
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
|
||||
#ifdef CRAY
|
||||
/*
|
||||
* IRIX (xfs) systems do not have the 1000 link limit.
|
||||
* I tried 100000 links on 2/97 without error on IRIX 6.4.
|
||||
*/
|
||||
/*
|
||||
* Now check that one more link will put you over the top
|
||||
*/
|
||||
sprintf(lname, "%s%d", Basename, cnt);
|
||||
|
||||
/*
|
||||
* Call link(2)
|
||||
*/
|
||||
TEST(link(Fname, lname));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_ERRNO == EMLINK ) {
|
||||
tst_resm(TPASS,
|
||||
"link(%s, %s) ret %d on %d link, errno:%d",
|
||||
Fname, lname, TEST_RETURN, nlinks+1, EMLINK);
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL,
|
||||
"link(%s, %s) ret %d on %d link, errno:%d, expected -1, errno:%d",
|
||||
Fname, lname, TEST_RETURN, nlinks+1,
|
||||
TEST_ERRNO, EMLINK);
|
||||
}
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL, "link(%s, %s) ret %d on %d link, expected -1, errno:%d",
|
||||
Fname, lname, TEST_RETURN, nlinks+1, EMLINK);
|
||||
}
|
||||
#endif /* CRAY */
|
||||
|
||||
for(cnt=1; cnt < nlinks; cnt++) {
|
||||
|
||||
sprintf(lname, "%s%d", Basename, cnt);
|
||||
|
||||
if (unlink(lname) == -1) {
|
||||
tst_res(TWARN, "unlink(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* help
|
||||
***************************************************************/
|
||||
void
|
||||
help()
|
||||
{
|
||||
printf(" -N #links : create #links hard links every iteration\n");
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
int fd;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(Fname,"%s_%d", BASENAME, getpid());
|
||||
if ((fd = open(Fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
} else if (close(fd) == -1) {
|
||||
tst_res(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
sprintf(Basename, "%s_%d.", BASENAME, getpid());
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
256
winsup/testsuite/winsup.api/ltp/lseek01.c
Normal file
256
winsup/testsuite/winsup.api/ltp/lseek01.c
Normal file
@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : lseek01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for lseek(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 3
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) lseek(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the lseek(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* lseek(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="lseek01"; /* Test program identifier. */
|
||||
int TST_TOTAL=3; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char Fname[255];
|
||||
int Fd;
|
||||
|
||||
int Whence[] = {SEEK_SET, SEEK_CUR, SEEK_END, -1};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
int ind;
|
||||
int offset;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
offset=(lc%100)*4096; /* max size is 100 blocks */
|
||||
|
||||
for (ind=0; Whence[ind] >= 0; ind++) {
|
||||
|
||||
/*
|
||||
* Call lseek(2)
|
||||
*/
|
||||
TEST(lseek(Fd, (long)offset, Whence[ind]));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "lseek(%s, %ld, 0) Failed, errno=%d : %s",
|
||||
Fname, offset, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "lseek(%s, %ld, %d) returned %d", Fname,
|
||||
offset, Whence[ind], TEST_RETURN);
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(Fname, "tfile_%d",getpid());
|
||||
if ((Fd = open(Fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the file we have open */
|
||||
if (close(Fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", Fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
243
winsup/testsuite/winsup.api/ltp/lseek02.c
Normal file
243
winsup/testsuite/winsup.api/ltp/lseek02.c
Normal file
@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : lseek02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Negative test for lseek(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 04/25/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) lseek(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the lseek(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* lseek(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="lseek02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
|
||||
int Whence[] = {SEEK_SET, SEEK_CUR, SEEK_END, -1};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call lseek(2)
|
||||
*/
|
||||
TEST( lseek(-1, (long)1, SEEK_SET) );
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
|
||||
if ( TEST_ERRNO == EBADF )
|
||||
|
||||
tst_resm(TPASS,
|
||||
"lseek(-1, 1, SEEK_SET) Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
else
|
||||
tst_resm(TFAIL,
|
||||
"lseek(-1, 1, SEEK_SET) Failed, errno=%d : %s, expected %d(EBADF)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO), EBADF);
|
||||
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
|
||||
} else {
|
||||
|
||||
tst_resm(TFAIL, "lseek(-1, 1, SEEK_SET) returned %d",
|
||||
TEST_RETURN);
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
257
winsup/testsuite/winsup.api/ltp/lseek04.c
Normal file
257
winsup/testsuite/winsup.api/ltp/lseek04.c
Normal file
@ -0,0 +1,257 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : lseek04
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Negative test for lseek(2) of a fifo
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 04/25/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) lseek(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the lseek(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* lseek(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="lseek04"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char Fname[255];
|
||||
int Fd;
|
||||
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call lseek(2)
|
||||
*/
|
||||
TEST(lseek(Fd, (long)1, SEEK_SET));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
|
||||
if ( TEST_ERRNO == ESPIPE )
|
||||
tst_resm(TPASS,
|
||||
"lseek(fifofd, 1, SEEK_SET) Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
else
|
||||
tst_resm(TFAIL,
|
||||
"lseek(fifofd, 1, SEEK_SET) Failed, errno=%d %s, expected %d(ESPIPE)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO),
|
||||
EINVAL);
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
} else {
|
||||
|
||||
tst_resm(TFAIL, "lseek(fifofd, 1, SEEK_SET) returned %d",
|
||||
TEST_RETURN);
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(Fname,"tfile_%d",getpid());
|
||||
if ( mkfifo(Fname,0700) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"mkfifo(%s, 0700) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
if ( (Fd=open(Fname, O_RDWR, 0777)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR, 0777) Failed, errno=%d : %s",
|
||||
Fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the file we have open */
|
||||
if (close(Fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", Fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
253
winsup/testsuite/winsup.api/ltp/lseek05.c
Normal file
253
winsup/testsuite/winsup.api/ltp/lseek05.c
Normal file
@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : lseek05
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Negative test for lseek(2) of a pipe
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 04/25/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) lseek(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the lseek(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* lseek(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="lseek05"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int Fd;
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call lseek(2)
|
||||
*/
|
||||
TEST(lseek(Fd, (long)1, SEEK_SET));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
|
||||
if ( TEST_ERRNO == ESPIPE )
|
||||
tst_resm(TPASS,
|
||||
"lseek(pipefd, 1, SEEK_SET) Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
else
|
||||
tst_resm(TFAIL,
|
||||
"lseek(pipefd, 1, SEEK_SET) Failed, errno=%d %s, expected %d(ESPIPE)",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO),
|
||||
EINVAL);
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
} else {
|
||||
|
||||
tst_resm(TFAIL, "lseek(pipefd, 1, SEEK_SET) returned %d",
|
||||
TEST_RETURN);
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
int fds[2];
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
if ( pipe(fds) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"pipe(&fds) Failed, errno=%d : %s", errno, strerror(errno));
|
||||
}
|
||||
Fd = fds[0];
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the file we have open */
|
||||
if (close(Fd) == -1) {
|
||||
tst_resm(TWARN, "close(%d) Failed, errno=%d : %s", Fd, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
253
winsup/testsuite/winsup.api/ltp/lstat02.c
Normal file
253
winsup/testsuite/winsup.api/ltp/lstat02.c
Normal file
@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : lstat02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for lstat(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) lstat(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the lstat(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* lstat(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="lstat02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255], lname[255], symlnk[255], buf[255];
|
||||
int fd;
|
||||
struct stat statter;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call lstat(2)
|
||||
*/
|
||||
TEST(lstat(symlnk, &statter));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "lstat(%s, &statter) Failed, errno=%d : %s", symlnk,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "lstat(%s, &statter) returned %d", symlnk, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
} else if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
sprintf(symlnk,"lnfile_%d",getpid());
|
||||
if (symlink(fname, symlnk) == -1) {
|
||||
tst_resm(TWARN, "symlink(%s, %s) Failed, errno=%d : %s",
|
||||
fname, symlnk, errno, strerror(errno));
|
||||
} else if (readlink(symlnk, buf, 255) == -1) {
|
||||
tst_resm(TWARN, "readlink(%s, buf, 255) Failed, errno=%d : %s",
|
||||
symlnk, errno, strerror(errno));
|
||||
} else if (strcmp(buf, fname) != 0) {
|
||||
tst_resm(TWARN,
|
||||
"Setup Failure : Expected symbolic link contents of %s : Actual is %s",
|
||||
fname, buf);
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
271
winsup/testsuite/winsup.api/ltp/mkdir01.c
Normal file
271
winsup/testsuite/winsup.api/ltp/mkdir01.c
Normal file
@ -0,0 +1,271 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : mkdir01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic errno test for mkdir(2)
|
||||
*
|
||||
* PARENT DOCUMENT : mkstds02
|
||||
*
|
||||
* TEST CASE TOTAL : 2
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Bill Branum
|
||||
*
|
||||
* CO-PILOT : Kathy Olmsted
|
||||
*
|
||||
* DATE STARTED : 4/15/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* mkdir(2) test for errno(s) EFAULT.
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This test will verify that mkdir(2) returns a value of
|
||||
* -1 and sets errno to EFAULT when the path argument points
|
||||
* outside (above/below) the allocated address space of the
|
||||
* process.
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Create and make current a temporary directory.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno.
|
||||
* If doing functional test
|
||||
* check the errno returned and print result message
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
* Remove the temporary directory.
|
||||
* Exit.
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
char *get_high_address();
|
||||
|
||||
char *TCID="mkdir01"; /* Test program identifier. */
|
||||
int TST_TOTAL=2; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={EFAULT, 0}; /* List must end with 0 */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* TEST CASE: 1
|
||||
* mkdir() call with pointer below allocated address space.
|
||||
*/
|
||||
|
||||
/* Call mkdir(2) */
|
||||
TEST(mkdir((char *)-1,0777));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if (TEST_ERRNO == EFAULT) {
|
||||
tst_resm(TPASS, "mkdir - path argument pointing below allocated address space failed as expected with errno %d : %s", TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL, "mkdir - path argument pointing below allocated address space failed with errno %d : %s but expected %d (EFAULT)", TEST_ERRNO, strerror(TEST_ERRNO),EFAULT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL, "mkdir - path argument pointing below allocated address space succeeded unexpectedly.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE: 2
|
||||
* mkdir() call with pointer above allocated address space.
|
||||
*/
|
||||
|
||||
/* Call mkdir(2) */
|
||||
TEST(mkdir(get_high_address(),0777));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if (TEST_ERRNO == EFAULT) {
|
||||
tst_resm(TPASS, "mkdir - path argument pointing above allocated address space failed as expected with errno %d : %s", TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL, "mkdir - path argument pointing above allocated address space failed with errno %d : %s but expected %d (EFAULT)", TEST_ERRNO, strerror(TEST_ERRNO),EFAULT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
tst_resm(TFAIL, "mkdir - path argument pointing above allocated address space succeeded unexpectedly.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Create a temporary directory and make it current. */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/*
|
||||
* Remove the temporary directory.
|
||||
*/
|
||||
tst_rmdir();
|
||||
|
||||
/*
|
||||
* Exit with return code appropriate for results.
|
||||
*/
|
||||
tst_exit();
|
||||
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
236
winsup/testsuite/winsup.api/ltp/mkdir08.c
Normal file
236
winsup/testsuite/winsup.api/ltp/mkdir08.c
Normal file
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : mkdir08
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for mkdir(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) mkdir(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the mkdir(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* mkdir(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="mkdir08"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call mkdir(2)
|
||||
*/
|
||||
TEST(mkdir(fname, 0777));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "mkdir(%s) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "mkdir(%s) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
if(rmdir(fname) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "rmdir(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname, "./dir_%d", getpid());
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
274
winsup/testsuite/winsup.api/ltp/mknod01.c
Normal file
274
winsup/testsuite/winsup.api/ltp/mknod01.c
Normal file
@ -0,0 +1,274 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : mknod01
|
||||
*
|
||||
* EXECUTED BY : root
|
||||
*
|
||||
* TEST TITLE : Basic test for mknod(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 4
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 05/13/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) mknod(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the mknod(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* mknod(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="mknod01"; /* Test program identifier. */
|
||||
int TST_TOTAL; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
char Path[1024]; /* path to create */
|
||||
int i; /* counter for test case loop */
|
||||
int tcases[] = { /* modes to give nodes created (1 per text case) */
|
||||
S_IFREG|0777, /* ordinary file with mode 0777 */
|
||||
S_IFIFO|0777, /* fifo special with mode 0777 */
|
||||
S_IFCHR|0777, /* character special with mode 0777 */
|
||||
S_IFBLK|0777, /* block special with mode 0777 */
|
||||
|
||||
S_IFREG|04700, /* ordinary file with mode 04700 (suid) */
|
||||
S_IFREG|02700, /* ordinary file with mode 02700 (sgid) */
|
||||
S_IFREG|06700, /* ordinary file with mode 06700 (sgid & suid) */
|
||||
|
||||
#ifdef CRAY
|
||||
S_IFDIR|0777, /* Direcory */
|
||||
S_IRESTART|0400, /* restartbit */
|
||||
#ifdef S_IFOFD
|
||||
S_IFOFD|0777, /* off line, with data */
|
||||
#endif
|
||||
#ifdef S_IFOFL
|
||||
S_IFOFL|0777, /* off line, with no data */
|
||||
#endif
|
||||
#endif /* CRAY */
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
TST_TOTAL=(sizeof(tcases)/sizeof(tcases[0]));
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASES:
|
||||
* Make nodes in tcases array
|
||||
*/
|
||||
for(i=0; i<TST_TOTAL; i++) {
|
||||
/* Call mknod(2) */
|
||||
TEST(mknod(Path, tcases[i], 0));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "mknod(%s, %#o, 0) failed, errno=%d : %s",
|
||||
Path, tcases[i], TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "mknod(%s, %#o, 0) returned %d",
|
||||
Path, tcases[i], TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
/* remove the node for the next go `round */
|
||||
if (unlink(Path) == -1 ) {
|
||||
if ( rmdir(Path) == -1 ) {
|
||||
tst_resm(TWARN, "unlink(%s) & rmdir(%s) failed, errno:%d %s",
|
||||
Path, Path, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp dir and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Check that user is root */
|
||||
if ( geteuid() != 0 )
|
||||
tst_brkm(TBROK, cleanup, "Must be root for this test!");
|
||||
|
||||
/* build a temp node name to bre created my mknod */
|
||||
sprintf(Path, "./tnode_%d", getpid());
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove files and temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
220
winsup/testsuite/winsup.api/ltp/nice05.c
Normal file
220
winsup/testsuite/winsup.api/ltp/nice05.c
Normal file
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : nice05
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for nice(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) nice(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the nice(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* nice(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="nice05"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int val;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
val = lc % 39;
|
||||
/*
|
||||
* Call nice(2)
|
||||
*/
|
||||
TEST(nice(val));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "nice(%d) Failed, errno=%d : %s", val,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "nice(%d) returned %d", val, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
243
winsup/testsuite/winsup.api/ltp/open03.c
Normal file
243
winsup/testsuite/winsup.api/ltp/open03.c
Normal file
@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : open03
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for open(2)
|
||||
*
|
||||
* PARENT DOCUMENT : xxxtds01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) open(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the open(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* open(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="open03"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call open(2)
|
||||
*/
|
||||
TEST(open(fname,O_RDWR|O_CREAT,0700));
|
||||
|
||||
fd=TEST_RETURN;
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "open(%s,O_RDWR|O_CREAT,0700) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "open(%s, O_RDWR|O_CREAT,0700) returned %d",
|
||||
fname, TEST_RETURN);
|
||||
}
|
||||
|
||||
if (close(fd) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"close(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
} else if (unlink(fname) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"unlink(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
246
winsup/testsuite/winsup.api/ltp/pathconf01.c
Normal file
246
winsup/testsuite/winsup.api/ltp/pathconf01.c
Normal file
@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : pathconf01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for pathconf(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 6
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) pathconf(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the pathconf(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* pathconf(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="pathconf01"; /* Test program identifier. */
|
||||
int TST_TOTAL; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int i;
|
||||
char *path = "/tmp";
|
||||
|
||||
struct pathconf_args
|
||||
{
|
||||
char *define_tag;
|
||||
int value;
|
||||
} args[] = {
|
||||
{"_PC_LINK_MAX", _PC_LINK_MAX},
|
||||
{"_PC_NAME_MAX", _PC_NAME_MAX},
|
||||
{"_PC_PATH_MAX", _PC_PATH_MAX},
|
||||
{"_PC_PIPE_BUF", _PC_PIPE_BUF},
|
||||
{"_PC_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED},
|
||||
{"_PC_NO_TRUNC", _PC_NO_TRUNC},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
TST_TOTAL=(sizeof(args)/sizeof(args[0]))-1;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for (i=0; i<TST_TOTAL; i++) {
|
||||
|
||||
errno=-4;
|
||||
|
||||
/*
|
||||
* Call pathconf(2)
|
||||
*/
|
||||
TEST(pathconf(path, args[i].value));
|
||||
|
||||
/*
|
||||
* A test case can only fail if -1 is returned and the errno
|
||||
* was set. If the errno remains unchanged, the
|
||||
* system call did not fail.
|
||||
*/
|
||||
if ( TEST_RETURN == -1 && errno != -4 ) {
|
||||
tst_resm(TFAIL, "pathconf(%s, %s) Failed, errno=%d : %s",
|
||||
path, args[i].define_tag,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "pathconf(%s, %s) returned %d",
|
||||
path, args[i].define_tag, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
229
winsup/testsuite/winsup.api/ltp/pause01.c
Normal file
229
winsup/testsuite/winsup.api/ltp/pause01.c
Normal file
@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : pause01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for pause(2)
|
||||
*
|
||||
* PARENT DOCUMENT : xxxtds01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 2
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) pause(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the pause(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* pause(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="pause01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={EINTR, 0};
|
||||
void go();
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
(void) signal(SIGALRM, go);
|
||||
alarm(1);
|
||||
/*
|
||||
* Call pause(2)
|
||||
*/
|
||||
TEST(pause());
|
||||
|
||||
/* check return code. Pause returns -1 and EINTR errno */
|
||||
if (TEST_RETURN != -1) {
|
||||
tst_resm(TFAIL,
|
||||
"pause() returned WITHOUT an error return code : %d",
|
||||
TEST_ERRNO);
|
||||
} else {
|
||||
/* log the errno */
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* check the errno */
|
||||
if (TEST_ERRNO == EINTR)
|
||||
tst_resm(TPASS, "pause() returned %d", TEST_RETURN);
|
||||
else
|
||||
tst_resm(TFAIL, "pause() returned %d. Expected %d (EINTR)",
|
||||
TEST_RETURN, EINTR);
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
|
||||
/* routine to catch the alarm signal */
|
||||
void
|
||||
go()
|
||||
{
|
||||
}
|
||||
244
winsup/testsuite/winsup.api/ltp/readlink02.c
Normal file
244
winsup/testsuite/winsup.api/ltp/readlink02.c
Normal file
@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : readlink02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for readlink(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) readlink(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the readlink(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* readlink(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="readlink02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
char fname[255], buf[255], symlnk[255];
|
||||
int fd;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call readlink(2)
|
||||
*/
|
||||
TEST(readlink(symlnk, buf, 255));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "readlink(%s, buf, 255) Failed, errno=%d : %s", symlnk,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "readlink(%s, buf, 255) returned %d", symlnk, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"./tfile_%d",getpid());
|
||||
if ((fd=open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
if (close(fd) == -1 ) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
sprintf(symlnk,"./sl_%d",getpid());
|
||||
if (symlink(fname, symlnk) == -1) {
|
||||
tst_resm(TWARN, "symlnk(%s, %s) Failed, errno=%d : %s",
|
||||
fname, symlnk, errno, strerror(errno));
|
||||
}
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
251
winsup/testsuite/winsup.api/ltp/rename02.c
Normal file
251
winsup/testsuite/winsup.api/ltp/rename02.c
Normal file
@ -0,0 +1,251 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : rename02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for rename(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) rename(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the rename(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* rename(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
void do_file_setup();
|
||||
|
||||
|
||||
|
||||
char *TCID="rename02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
int fd;
|
||||
char fname[255], mname[255];
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call rename(2)
|
||||
*/
|
||||
TEST(rename(fname, mname));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "rename(%s, %s) Failed, errno=%d : %s", fname, mname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "rename(%s, %s) returned %d", fname, mname, TEST_RETURN);
|
||||
}
|
||||
if (unlink(mname) == -1) {
|
||||
tst_resm(TWARN, "unlink(%s) Failed, errno=%d : %s", mname, errno, strerror(errno));
|
||||
}
|
||||
do_file_setup();
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"./tfile_%d",getpid());
|
||||
sprintf(mname,"./rnfile_%d",getpid());
|
||||
do_file_setup();
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
|
||||
} /* End cleanup() */
|
||||
|
||||
void
|
||||
do_file_setup()
|
||||
{
|
||||
if ((fd=open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
if (close(fd) == -1 )
|
||||
tst_resm(TWARN, "close(%s) Failed on file create, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
|
||||
}
|
||||
237
winsup/testsuite/winsup.api/ltp/rmdir04.c
Normal file
237
winsup/testsuite/winsup.api/ltp/rmdir04.c
Normal file
@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : rmdir04
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for rmdir(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) rmdir(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the rmdir(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* rmdir(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="rmdir04"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
char *cwd;
|
||||
char fname[255];
|
||||
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
if (mkdir(fname, 0777) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"mkdir(%s) Failure. errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
/*
|
||||
* Call rmdir(2)
|
||||
*/
|
||||
TEST(rmdir(fname));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "rmdir(%s) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "rmdir(%s) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname, "./dir_%d", getpid());
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
276
winsup/testsuite/winsup.api/ltp/select01.c
Normal file
276
winsup/testsuite/winsup.api/ltp/select01.c
Normal file
@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : select01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : select to a file
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 3
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 02/24/93
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) select(2) to a fd of regular file with no I/O and small timeout
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the select(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* join(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h> /* For open system call parameters. */
|
||||
#include <signal.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
/*
|
||||
FIXME: workaround for bug in newlib -- FD_ZERO is defined via bzero and
|
||||
if we don't include strings.h compiler warns about implicit declaration
|
||||
*/
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
#define FILENAME "select01"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
char *TCID="select01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int Fd;
|
||||
fd_set Readfds;
|
||||
|
||||
/***********************************************************************
|
||||
* MAIN
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
struct timeval timeout;
|
||||
long test_time = 0; /* in usecs */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options, and exit if there is an error
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Assigning the specified seconds within the timeval structure.
|
||||
*/
|
||||
test_time = ((lc%2000)*100000); /* 100 milli-seconds */
|
||||
|
||||
/*
|
||||
* Bound the time to a value less than 60 seconds
|
||||
*/
|
||||
|
||||
if ( test_time > 1000000 * 60 )
|
||||
test_time = test_time % (1000000 * 60);
|
||||
|
||||
timeout.tv_sec = test_time / 1000000;
|
||||
timeout.tv_usec = test_time - (timeout.tv_sec * 1000000);
|
||||
|
||||
|
||||
/* Call the system call being tested. */
|
||||
TEST(select(4, &Readfds, 0, 0, &timeout));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL,
|
||||
"%d select(4, &Readfds, 0, 0, &timeout), timeout = %ld usecs, errno=%d",
|
||||
lc, test_time, errno);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* Perform functional verification here */
|
||||
tst_resm(TPASS,
|
||||
"select(4, &Readfds, 0, 0, &timeout) timeout = %ld usecs",
|
||||
test_time);
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* create a temporary directory and go to it */
|
||||
tst_tmpdir();
|
||||
|
||||
if ((Fd=open(FILENAME, O_CREAT | O_RDWR)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_CREAT | O_RDWR) failed: errno:%d\n",
|
||||
errno);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializing and assigning the standard output file descriptor to
|
||||
* fd_set for select.
|
||||
*/
|
||||
|
||||
FD_ZERO(&Readfds);
|
||||
FD_SET(Fd, &Readfds);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
close(Fd);
|
||||
|
||||
/* remove temporary directory and all files in it. */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
219
winsup/testsuite/winsup.api/ltp/setgid01.c
Normal file
219
winsup/testsuite/winsup.api/ltp/setgid01.c
Normal file
@ -0,0 +1,219 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : setgid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for setgid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) setgid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the setgid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* setgid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="setgid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
int gid;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call setgid(2)
|
||||
*/
|
||||
TEST(setgid(gid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setgid(%d) Failed, errno=%d : %s", gid,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setgid(%d) returned %d", gid, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
gid = getgid();
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
229
winsup/testsuite/winsup.api/ltp/setgroups01.c
Normal file
229
winsup/testsuite/winsup.api/ltp/setgroups01.c
Normal file
@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : setgroups01
|
||||
*
|
||||
* EXECUTED BY : root
|
||||
*
|
||||
* TEST TITLE : Basic test for setgroups(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) setgroups(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the setgroups(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* setgroups(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/param.h>
|
||||
#include <unistd.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="setgroups01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int len = NGROUPS;
|
||||
gid_t list[NGROUPS];
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call setgroups(2)
|
||||
*/
|
||||
TEST(setgroups(len, list));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setgroups(%d, list) Failed, errno=%d : %s", len,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setgroups(%d, list) returned %d", len, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
if ( geteuid() != 0 )
|
||||
tst_brkm(TBROK, cleanup, "Must be ROOT to run this test.");
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
if (getgroups(len, list) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"getgroups(%d, list) Failure. errno=%d : %s",
|
||||
len, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
240
winsup/testsuite/winsup.api/ltp/setpgid01.c
Normal file
240
winsup/testsuite/winsup.api/ltp/setpgid01.c
Normal file
@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : setpgid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for setpgid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) setpgid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the setpgid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* setpgid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="setpgid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
int pgid, pid;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call setpgid(2)
|
||||
*/
|
||||
TEST(setpgid(pid, pgid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setpgid(%d, %d) Failed, errno=%d : %s", pid, pgid,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setpgid(%d, %d) returned %d", pid, pgid, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
int status;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
/*
|
||||
* Make sure current process is NOT a session or pgrp leader
|
||||
*/
|
||||
|
||||
pgid=getpgrp();
|
||||
pid=getpid();
|
||||
|
||||
if (pgid == pid) {
|
||||
if ((pid = fork()) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "fork() in setup() failed - errno %d",
|
||||
errno);
|
||||
}
|
||||
|
||||
if (pid != 0) { /* parent - sits and waits */
|
||||
wait(&status);
|
||||
exit(WEXITSTATUS(status));
|
||||
} else { /* child - continues with test */
|
||||
pid = getpid();
|
||||
}
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
338
winsup/testsuite/winsup.api/ltp/setregid01.c
Normal file
338
winsup/testsuite/winsup.api/ltp/setregid01.c
Normal file
@ -0,0 +1,338 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : setregid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for setregid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 5
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 05/13/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) setregid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the setregid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* setregid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="setregid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=5; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0}; /* Zero terminated list of expected errnos */
|
||||
|
||||
int gid, egid; /* current real and effective group id */
|
||||
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* Dont change either real or effective gid
|
||||
*/
|
||||
gid=getgid();
|
||||
egid=getegid();
|
||||
|
||||
|
||||
/* Call setregid(2) */
|
||||
TEST(setregid(-1, -1));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setregid - Dont change either real or effective gid failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setregid - Dont change either real or effective gid returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* change effective to effective gid
|
||||
*/
|
||||
|
||||
|
||||
/* Call setregid(2) */
|
||||
TEST(setregid(-1, egid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setregid - change effective to effective gid failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setregid - change effective to effective gid returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* change real to real gid
|
||||
*/
|
||||
|
||||
|
||||
/* Call setregid(2) */
|
||||
TEST(setregid(gid, -1));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setregid - change real to real gid failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setregid - change real to real gid returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* change effective to real gid
|
||||
*/
|
||||
|
||||
|
||||
/* Call setregid(2) */
|
||||
TEST(setregid(-1, gid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setregid - change effective to real gid failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setregid - change effective to real gid returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* try to change real to current real
|
||||
*/
|
||||
|
||||
|
||||
/* Call setregid(2) */
|
||||
TEST(setregid(gid, gid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setregid - try to change real to current real failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setregid - try to change real to current real returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp dir and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove files and temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
338
winsup/testsuite/winsup.api/ltp/setreuid01.c
Normal file
338
winsup/testsuite/winsup.api/ltp/setreuid01.c
Normal file
@ -0,0 +1,338 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : setreuid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for setreuid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 5
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 05/14/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) setreuid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the setreuid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* setreuid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="setreuid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=5; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0}; /* Zero terminated list of expected errnos */
|
||||
|
||||
int ruid, euid; /* real and effective user ids */
|
||||
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* Don't change either real or effective uid
|
||||
*/
|
||||
ruid=getuid(); /* get real uid */
|
||||
euid=geteuid(); /* get effective uid */
|
||||
|
||||
|
||||
/* Call setreuid(2) */
|
||||
TEST(setreuid(-1, -1));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setreuid - Don't change either real or effective uid failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setreuid - Don't change either real or effective uid returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* change effective to effective uid
|
||||
*/
|
||||
|
||||
|
||||
/* Call setreuid(2) */
|
||||
TEST(setreuid(-1, euid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setreuid - change effective to effective uid failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setreuid - change effective to effective uid returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* change real to real uid
|
||||
*/
|
||||
|
||||
|
||||
/* Call setreuid(2) */
|
||||
TEST(setreuid(ruid, -1));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setreuid - change real to real uid failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setreuid - change real to real uid returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* change effective to real uid
|
||||
*/
|
||||
|
||||
|
||||
/* Call setreuid(2) */
|
||||
TEST(setreuid(-1, ruid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setreuid - change effective to real uid failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setreuid - change effective to real uid returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* try to change real to current real
|
||||
*/
|
||||
|
||||
|
||||
/* Call setreuid(2) */
|
||||
TEST(setreuid(ruid, ruid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setreuid - try to change real to current real failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setreuid - try to change real to current real returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp dir and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove files and temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
225
winsup/testsuite/winsup.api/ltp/setuid01.c
Normal file
225
winsup/testsuite/winsup.api/ltp/setuid01.c
Normal file
@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : setuid01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for setuid(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 05/14/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) setuid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* The libcuts.a and libsys.a libraries must be included in
|
||||
* the compilation of this test.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the setuid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* setuid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="setuid01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int uid; /* current user id */
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* Set the effective user ID to the current real uid
|
||||
*/
|
||||
uid=getuid();
|
||||
|
||||
/* Call setuid(2) */
|
||||
TEST(setuid(uid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setuid - Set the effective user ID to the current real uid failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setuid - Set the effective user ID to the current real uid returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
|
||||
|
||||
240
winsup/testsuite/winsup.api/ltp/setuid02.c
Normal file
240
winsup/testsuite/winsup.api/ltp/setuid02.c
Normal file
@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : setuid02
|
||||
*
|
||||
* EXECUTED BY : root
|
||||
*
|
||||
* TEST TITLE : Basic test for setuid(2) as root
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 05/14/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) setuid(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the setuid(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* setuid(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="setuid02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0}; /* Zero terminated list of expected errnos */
|
||||
|
||||
int uid; /* current user id */
|
||||
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
uid=getuid();
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
/*
|
||||
* TEST CASE:
|
||||
* Set the effective user ID to the current real uid
|
||||
*/
|
||||
|
||||
/* Call setuid(2) */
|
||||
TEST(setuid(uid));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "setuid - Set the effective user ID to the current real uid failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "setuid - Set the effective user ID to the current real uid returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp dir and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* must be root */
|
||||
if ( geteuid() != 0 )
|
||||
tst_brkm(TBROK, cleanup, "Must be root for this test!");
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* remove files and temp dir */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
241
winsup/testsuite/winsup.api/ltp/stat05.c
Normal file
241
winsup/testsuite/winsup.api/ltp/stat05.c
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : stat05
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for stat(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) stat(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the stat(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* stat(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="stat05"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
struct stat statter;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call stat(2) with F_CLRALF argument on fname
|
||||
*/
|
||||
TEST(stat(fname, &statter));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "stat(%s, &statter) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "stat(%s, &statter) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
2024
winsup/testsuite/winsup.api/ltp/symlink01.c
Normal file
2024
winsup/testsuite/winsup.api/ltp/symlink01.c
Normal file
File diff suppressed because it is too large
Load Diff
245
winsup/testsuite/winsup.api/ltp/symlink02.c
Normal file
245
winsup/testsuite/winsup.api/ltp/symlink02.c
Normal file
@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : symlink02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for symlink(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) symlink(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the symlink(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* symlink(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="symlink02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255], symlnk[255];
|
||||
int fd;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call symlink(2)
|
||||
*/
|
||||
TEST(symlink(fname, symlnk));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "symlink(%s, %s) Failed, errno=%d : %s",
|
||||
fname, symlnk, TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "symlink(%s, %s) returned %d",
|
||||
fname, symlnk, TEST_RETURN);
|
||||
}
|
||||
if (unlink(symlnk) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"unlink(%s) Failed, errno=%d : %s",
|
||||
symlnk, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd=open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
if (close(fd) == -1 ) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
sprintf(symlnk,"st_%d",getpid());
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
216
winsup/testsuite/winsup.api/ltp/sync01.c
Normal file
216
winsup/testsuite/winsup.api/ltp/sync01.c
Normal file
@ -0,0 +1,216 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : sync01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for sync(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) sync(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the sync(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* sync(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="sync01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call sync(2)
|
||||
*/
|
||||
TEST_VOID(sync());
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "sync() Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "sync() returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
218
winsup/testsuite/winsup.api/ltp/time01.c
Normal file
218
winsup/testsuite/winsup.api/ltp/time01.c
Normal file
@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : time01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for time(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) time(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the time(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* time(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="time01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call time(2)
|
||||
*/
|
||||
TEST(time(0));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "time(0) Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "time(0) returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
void trapper();
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
222
winsup/testsuite/winsup.api/ltp/times01.c
Normal file
222
winsup/testsuite/winsup.api/ltp/times01.c
Normal file
@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : times01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for times(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) times(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the times(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* times(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/times.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="times01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
struct tms mytimes;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call times(2)
|
||||
*/
|
||||
TEST(times(&mytimes));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "times(&mytimes) Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "times(&mytimes) returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
void trapper();
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
273
winsup/testsuite/winsup.api/ltp/ulimit01.c
Normal file
273
winsup/testsuite/winsup.api/ltp/ulimit01.c
Normal file
@ -0,0 +1,273 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : ulimit01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for ulimit(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 6
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) ulimit(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* The libcuts.a and libsys.a libraries must be included in
|
||||
* the compilation of this test.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the ulimit(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* ulimit(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <ulimit.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="ulimit01"; /* Test program identifier. */
|
||||
int TST_TOTAL=6; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int cmd;
|
||||
long limit; /* saved limit */
|
||||
|
||||
struct limits_t {
|
||||
int cmd;
|
||||
long newlimit;
|
||||
int nlim_flag; /* special flag for UL_SETFSIZE records */
|
||||
int exp_fail;
|
||||
} Scenarios[] = {
|
||||
|
||||
{ UL_GETFSIZE, -1, 0, 0 },
|
||||
{ UL_SETFSIZE, -1, 0, 1 }, /* negative test */
|
||||
{ UL_SETFSIZE, -2, 1, 0 }, /* case case: must be after UL_GETFSIZE */
|
||||
{ UL_SETFSIZE, -2, 2, 0 }, /* case case: must be after UL_GETFSIZE */
|
||||
|
||||
#if UL_GMEMLIM
|
||||
{ UL_GMEMLIM, -1, 0, 0 },
|
||||
#endif
|
||||
#if UL_GDESLIM
|
||||
{ UL_GDESLIM, -1, 0, 0 },
|
||||
#endif
|
||||
#if UL_GSHMEMLIM
|
||||
{ UL_GSHMEMLIM, -1, 0, 0 },
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
int i; /* inner loop (test case) counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
int tmp;
|
||||
|
||||
TST_TOTAL = sizeof(Scenarios)/sizeof(struct limits_t);
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
for ( i=0; i<TST_TOTAL; i++) {
|
||||
|
||||
cmd=Scenarios[i].cmd;
|
||||
limit=Scenarios[i].newlimit;
|
||||
|
||||
/*
|
||||
* Call ulimit(2)
|
||||
*/
|
||||
TEST(ulimit(cmd, limit));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if ( Scenarios[i].exp_fail ) {
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
tst_resm(TPASS, "ulimit(%d, %d) Failed, errno=%d : %s", cmd, limit,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
} else {
|
||||
tst_resm(TFAIL, "ulimit(%d, %d) Failed, errno=%d : %s", cmd, limit,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
}
|
||||
} else {
|
||||
if ( Scenarios[i].exp_fail ) {
|
||||
tst_resm(TFAIL, "ulimit(%d, %d) returned %d",
|
||||
cmd, limit, TEST_RETURN);
|
||||
} else if ( STD_FUNCTIONAL_TEST ) {
|
||||
tst_resm(TPASS, "ulimit(%d, %d) returned %d",
|
||||
cmd, limit, TEST_RETURN);
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the UL_GETFSIZE return value in the newlimit field
|
||||
* for UL_SETFSIZE test cases.
|
||||
*/
|
||||
if ( cmd == UL_GETFSIZE ) {
|
||||
for (tmp=i+1; tmp<TST_TOTAL; tmp++) {
|
||||
if ( Scenarios[tmp].nlim_flag == 1 ) {
|
||||
Scenarios[tmp].newlimit = TEST_RETURN;
|
||||
}
|
||||
if ( Scenarios[tmp].nlim_flag == 2 ) {
|
||||
Scenarios[tmp].newlimit = TEST_RETURN-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
220
winsup/testsuite/winsup.api/ltp/umask01.c
Normal file
220
winsup/testsuite/winsup.api/ltp/umask01.c
Normal file
@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : umask01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for umask(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) umask(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the umask(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* umask(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="umask01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call umask(2)
|
||||
*/
|
||||
TEST(umask(022));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "umask(022) Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "umask(022) returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
void trapper();
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
221
winsup/testsuite/winsup.api/ltp/uname01.c
Normal file
221
winsup/testsuite/winsup.api/ltp/uname01.c
Normal file
@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : uname01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for uname(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) uname(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the uname(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* uname(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/utsname.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="uname01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
struct utsname un;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call uname(2)
|
||||
*/
|
||||
TEST(uname(&un));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "uname(&un) Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "uname(&un) returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
void trapper();
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
246
winsup/testsuite/winsup.api/ltp/unlink05.c
Normal file
246
winsup/testsuite/winsup.api/ltp/unlink05.c
Normal file
@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : unlink05
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for unlink(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) unlink(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the unlink(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* unlink(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
void create_file();
|
||||
|
||||
|
||||
|
||||
char *TCID="unlink05"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call unlink(2)
|
||||
*/
|
||||
TEST(unlink(fname));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "unlink(%s) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "unlink(%s) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
/* recreate file for next loop */
|
||||
create_file();
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
create_file();
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
void
|
||||
create_file()
|
||||
{
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
255
winsup/testsuite/winsup.api/ltp/unlink06.c
Normal file
255
winsup/testsuite/winsup.api/ltp/unlink06.c
Normal file
@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : unlink06
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : unlink(2) of a FIFO
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 03/30/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) unlink(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the unlink(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* unlink(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void create_file();
|
||||
void cleanup();
|
||||
|
||||
|
||||
char *TCID="unlink06"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char Fname[255];
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
create_file();
|
||||
|
||||
/*
|
||||
* Call unlink(2)
|
||||
*/
|
||||
TEST(unlink(Fname));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "unlink(%s) Failed, errno=%d : %s", Fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( access(Fname, F_OK) != -1 ) {
|
||||
tst_resm(TFAIL,
|
||||
"unlink(%s) returned %d, but access says file still exists.",
|
||||
Fname, TEST_RETURN);
|
||||
}
|
||||
else {
|
||||
tst_resm(TPASS, "unlink(%s) returned %d", Fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
sprintf(Fname, "fifo_unlink%d", getpid());
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
|
||||
} /* End cleanup() */
|
||||
|
||||
/******************************************************************
|
||||
*
|
||||
******************************************************************/
|
||||
void
|
||||
create_file()
|
||||
{
|
||||
if(mkfifo(Fname, 0777) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"mkfifo(%s, 0777) failed errno:%d %s\n", Fname,
|
||||
errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
329
winsup/testsuite/winsup.api/ltp/unlink07.c
Normal file
329
winsup/testsuite/winsup.api/ltp/unlink07.c
Normal file
@ -0,0 +1,329 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : unlink07
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : unlink(2) negative testcases
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : Richard Logan
|
||||
*
|
||||
* CO-PILOT : William Roske
|
||||
*
|
||||
* DATE STARTED : 03/30/94
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1-8) See Testcases structure below.
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the unlink(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* unlink(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/param.h> /* for PATH_MAX */
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
void setup();
|
||||
void cleanup();
|
||||
|
||||
|
||||
extern char *get_high_address();
|
||||
|
||||
char *TCID="unlink07"; /* Test program identifier. */
|
||||
int TST_TOTAL=6; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int longpath_setup();
|
||||
int no_setup();
|
||||
int filepath_setup();
|
||||
char Longpathname[PATH_MAX+2];
|
||||
char High_address[64];
|
||||
|
||||
struct test_case_t {
|
||||
char *pathname;
|
||||
char *desc;
|
||||
int exp_errno;
|
||||
int (*setupfunc)();
|
||||
} Test_cases[] = {
|
||||
{ "nonexistfile", "non-existent file", ENOENT, no_setup},
|
||||
{ "", "path is empty string", ENOENT, no_setup},
|
||||
{ "nefile/file", "path contains a non-existent file",
|
||||
ENOENT, no_setup },
|
||||
{ High_address, "address beyond address space", EFAULT, no_setup },
|
||||
#ifndef __CYGWIN__
|
||||
{ "file/file", "path contains a regular file",
|
||||
ENOTDIR, filepath_setup },
|
||||
#endif
|
||||
{ High_address, "address beyond address space", EFAULT, no_setup },
|
||||
{ Longpathname, "pathname too long", ENAMETOOLONG, longpath_setup },
|
||||
{ (char *)-1, "negative address", EFAULT, no_setup },
|
||||
{ NULL, NULL, 0, no_setup }
|
||||
};
|
||||
|
||||
/***********************************************************************
|
||||
* Main
|
||||
***********************************************************************/
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
char *fname;
|
||||
char *desc;
|
||||
int ind;
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
|
||||
for (ind=0; Test_cases[ind].desc != NULL; ind++ ) {
|
||||
|
||||
fname = Test_cases[ind].pathname;
|
||||
desc = Test_cases[ind].desc;
|
||||
|
||||
if ( fname == High_address )
|
||||
fname = get_high_address();
|
||||
|
||||
/*
|
||||
* Call unlink(2)
|
||||
*/
|
||||
TEST(unlink(fname));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
if ( TEST_ERRNO == Test_cases[ind].exp_errno )
|
||||
tst_resm(TPASS, "unlink(<%s>) Failed, errno=%d",
|
||||
desc, TEST_ERRNO);
|
||||
else
|
||||
tst_resm(TFAIL,
|
||||
"unlink(<%s>) Failed, errno=%d, expected errno:%d",
|
||||
desc, TEST_ERRNO, Test_cases[ind].exp_errno);
|
||||
}
|
||||
else
|
||||
Tst_count++;
|
||||
} else {
|
||||
tst_resm(TFAIL,
|
||||
"unlink(<%s>) returned %d, expected -1, errno:%d",
|
||||
desc, TEST_RETURN, Test_cases[ind].exp_errno);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
int ind;
|
||||
|
||||
/* capture signals */
|
||||
tst_sig(NOFORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
for (ind=0; Test_cases[ind].desc != NULL; ind++ ) {
|
||||
Test_cases[ind].setupfunc();
|
||||
}
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
chmod("unwrite_dir", 0777);
|
||||
chmod("unsearch_dir", 0777);
|
||||
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
|
||||
} /* End cleanup() */
|
||||
|
||||
/******************************************************************
|
||||
*
|
||||
******************************************************************/
|
||||
int
|
||||
no_setup()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
*
|
||||
******************************************************************/
|
||||
int
|
||||
longpath_setup()
|
||||
{
|
||||
int ind;
|
||||
|
||||
for(ind=0; ind<= PATH_MAX+1; ind++) {
|
||||
Longpathname[ind] = 'a';
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
/******************************************************************
|
||||
*
|
||||
******************************************************************/
|
||||
int
|
||||
filepath_setup()
|
||||
{
|
||||
int fd;
|
||||
|
||||
if ( (fd=creat("file", 0777)) == -1 ) {
|
||||
tst_brkm(TBROK, cleanup, "creat(file) failed, errno:%d %s",
|
||||
errno, strerror(errno));
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
230
winsup/testsuite/winsup.api/ltp/wait02.c
Normal file
230
winsup/testsuite/winsup.api/ltp/wait02.c
Normal file
@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : wait02
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for wait(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) wait(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the wait(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* wait(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="wait02"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
int fork_pid, ret_code;
|
||||
void trapper();
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL )
|
||||
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/* create a child to wait for */
|
||||
if ((fork_pid=fork()) == -1) {
|
||||
tst_brkm(TBROK, cleanup, "fork() Failure. errno=%d : %s", errno, strerror(errno));
|
||||
} else if (fork_pid == 0) {
|
||||
/* Child, sleep a second then exit */
|
||||
sleep(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Parent, wait for child to die */
|
||||
TEST(wait(&ret_code));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "wait(1) Failed, errno=%d : %s",
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "wait(&ret_code) returned %d", TEST_RETURN);
|
||||
}
|
||||
}
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
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() */
|
||||
|
||||
|
||||
250
winsup/testsuite/winsup.api/ltp/write01.c
Normal file
250
winsup/testsuite/winsup.api/ltp/write01.c
Normal file
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of version 2 of the GNU General Public License as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it would be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Further, this software is distributed without any warranty that it is
|
||||
* free of the rightful claim of any third person regarding infringement
|
||||
* or the like. Any license provided herein, whether implied or
|
||||
* otherwise, applies only to this software file. Patent licenses, if
|
||||
* any, provided herein do not apply to combinations of this program with
|
||||
* other software, or any other product whatsoever.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write the Free Software Foundation, Inc., 59
|
||||
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
||||
*
|
||||
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
||||
* Mountain View, CA 94043, or:
|
||||
*
|
||||
* http://www.sgi.com
|
||||
*
|
||||
* For further information regarding this notice, see:
|
||||
*
|
||||
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
|
||||
*
|
||||
*/
|
||||
/* $Id$ */
|
||||
/**********************************************************
|
||||
*
|
||||
* OS Test - Silicon Graphics, Inc.
|
||||
*
|
||||
* TEST IDENTIFIER : write01
|
||||
*
|
||||
* EXECUTED BY : anyone
|
||||
*
|
||||
* TEST TITLE : Basic test for write(2)
|
||||
*
|
||||
* PARENT DOCUMENT : usctpl01
|
||||
*
|
||||
* TEST CASE TOTAL : 1
|
||||
*
|
||||
* WALL CLOCK TIME : 1
|
||||
*
|
||||
* CPU TYPES : ALL
|
||||
*
|
||||
* AUTHOR : William Roske
|
||||
*
|
||||
* CO-PILOT : Dave Fenner
|
||||
*
|
||||
* DATE STARTED : 03/30/92
|
||||
*
|
||||
* INITIAL RELEASE : UNICOS 7.0
|
||||
*
|
||||
* TEST CASES
|
||||
*
|
||||
* 1.) write(2) returns...(See Description)
|
||||
*
|
||||
* INPUT SPECIFICATIONS
|
||||
* The standard options for system call tests are accepted.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* OUTPUT SPECIFICATIONS
|
||||
*
|
||||
* DURATION
|
||||
* Terminates - with frequency and infinite modes.
|
||||
*
|
||||
* SIGNALS
|
||||
* Uses SIGUSR1 to pause before test if option set.
|
||||
* (See the parse_opts(3) man page).
|
||||
*
|
||||
* RESOURCES
|
||||
* None
|
||||
*
|
||||
* ENVIRONMENTAL NEEDS
|
||||
* No run-time environmental needs.
|
||||
*
|
||||
* SPECIAL PROCEDURAL REQUIREMENTS
|
||||
* None
|
||||
*
|
||||
* INTERCASE DEPENDENCIES
|
||||
* None
|
||||
*
|
||||
* DETAILED DESCRIPTION
|
||||
* This is a Phase I test for the write(2) system call. It is intended
|
||||
* to provide a limited exposure of the system call, for now. It
|
||||
* should/will be extended when full functional tests are written for
|
||||
* write(2).
|
||||
*
|
||||
* Setup:
|
||||
* Setup signal handling.
|
||||
* Pause for SIGUSR1 if option specified.
|
||||
*
|
||||
* Test:
|
||||
* Loop if the proper options are given.
|
||||
* Execute system call
|
||||
* Check return code, if system call failed (return=-1)
|
||||
* Log the errno and Issue a FAIL message.
|
||||
* Otherwise, Issue a PASS message.
|
||||
*
|
||||
* Cleanup:
|
||||
* Print errno log and/or timing stats if options given
|
||||
*
|
||||
* UPDATE HISTORY
|
||||
* user date description
|
||||
* ------------------------------------------------------
|
||||
* wermager 3/00 Switched sequence of calls to TEST_PAUSE
|
||||
* and tst_tmpdir() in setup().
|
||||
*
|
||||
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include "test.h"
|
||||
#include "usctest.h"
|
||||
|
||||
extern void setup();
|
||||
extern void cleanup();
|
||||
|
||||
|
||||
|
||||
char *TCID="write01"; /* Test program identifier. */
|
||||
int TST_TOTAL=1; /* Total number of test cases. */
|
||||
extern int Tst_count; /* Test Case counter for tst_* routines */
|
||||
|
||||
int exp_enos[]={0, 0};
|
||||
|
||||
char fname[255];
|
||||
int fd;
|
||||
char buf = 'w';
|
||||
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
int lc; /* loop counter */
|
||||
char *msg; /* message returned from parse_opts */
|
||||
|
||||
/***************************************************************
|
||||
* parse standard options
|
||||
***************************************************************/
|
||||
if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
|
||||
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
|
||||
tst_exit();
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
* perform global setup for test
|
||||
***************************************************************/
|
||||
setup();
|
||||
|
||||
/* set the expected errnos... */
|
||||
TEST_EXP_ENOS(exp_enos);
|
||||
|
||||
/***************************************************************
|
||||
* check looping state if -c option given
|
||||
***************************************************************/
|
||||
for (lc=0; TEST_LOOPING(lc); lc++) {
|
||||
|
||||
/* reset Tst_count in case we are looping. */
|
||||
Tst_count=0;
|
||||
|
||||
/*
|
||||
* Call write(2)
|
||||
*/
|
||||
TEST(write(fd, &buf, 1));
|
||||
|
||||
/* check return code */
|
||||
if ( TEST_RETURN == -1 ) {
|
||||
TEST_ERROR_LOG(TEST_ERRNO);
|
||||
tst_resm(TFAIL, "write(%s, F_CLRALF, 1) Failed, errno=%d : %s", fname,
|
||||
TEST_ERRNO, strerror(TEST_ERRNO));
|
||||
} else {
|
||||
/***************************************************************
|
||||
* only perform functional verification if flag set (-f not given)
|
||||
***************************************************************/
|
||||
if ( STD_FUNCTIONAL_TEST ) {
|
||||
/* No Verification test, yet... */
|
||||
tst_resm(TPASS, "write(%s, F_CLRALF, 1) returned %d", fname, TEST_RETURN);
|
||||
}
|
||||
}
|
||||
|
||||
} /* End for TEST_LOOPING */
|
||||
|
||||
/***************************************************************
|
||||
* cleanup and exit
|
||||
***************************************************************/
|
||||
cleanup();
|
||||
|
||||
return 0;
|
||||
} /* End main */
|
||||
|
||||
/***************************************************************
|
||||
* setup() - performs all ONE TIME setup for this test.
|
||||
***************************************************************/
|
||||
void
|
||||
setup()
|
||||
{
|
||||
/* capture signals */
|
||||
tst_sig(FORK, DEF_HANDLER, cleanup);
|
||||
|
||||
|
||||
/* Pause if that option was specified */
|
||||
TEST_PAUSE;
|
||||
|
||||
/* make a temp directory and cd to it */
|
||||
tst_tmpdir();
|
||||
|
||||
sprintf(fname,"tfile_%d",getpid());
|
||||
if ((fd = open(fname,O_RDWR|O_CREAT,0700)) == -1) {
|
||||
tst_brkm(TBROK, cleanup,
|
||||
"open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s",
|
||||
fname, errno, strerror(errno));
|
||||
}
|
||||
} /* End setup() */
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* cleanup() - performs all ONE TIME cleanup for this test at
|
||||
* completion or premature exit.
|
||||
***************************************************************/
|
||||
void
|
||||
cleanup()
|
||||
{
|
||||
/*
|
||||
* print timing stats if that option was specified.
|
||||
* print errno log if that option was specified.
|
||||
*/
|
||||
TEST_CLEANUP;
|
||||
|
||||
/* close the file we have open */
|
||||
if (close(fd) == -1) {
|
||||
tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", fname, errno, strerror(errno));
|
||||
}
|
||||
|
||||
/* Remove tmp dir and all files in it */
|
||||
tst_rmdir();
|
||||
|
||||
/* exit with return code appropriate for results */
|
||||
tst_exit();
|
||||
} /* End cleanup() */
|
||||
|
||||
|
||||
20
winsup/testsuite/winsup.api/sigchld.c
Normal file
20
winsup/testsuite/winsup.api/sigchld.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
int no_signal_caught = 1;
|
||||
|
||||
void handler ( int signo )
|
||||
{
|
||||
no_signal_caught = 0;
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
pid_t pid;
|
||||
signal ( SIGCHLD, handler );
|
||||
pid = fork();
|
||||
if ( pid == 0 ) exit ( 0 );
|
||||
sleep ( 2 );
|
||||
exit ( no_signal_caught );
|
||||
}
|
||||
22
winsup/testsuite/winsup.api/waitpid.c
Normal file
22
winsup/testsuite/winsup.api/waitpid.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/wait.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int pid, n;
|
||||
if ((pid = fork ()) == 0)
|
||||
exit (0);
|
||||
sleep (2);
|
||||
if ((n = waitpid (pid, NULL, 0)) != pid)
|
||||
{
|
||||
printf ("wait pid failed, pid %d, n %d, errno %d\n", pid, n, errno);
|
||||
exit(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("wait pid succeeded, pid %d, n %d, errno %d\n", pid, n, errno);
|
||||
exit (0);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
source "site.exp"
|
||||
source "$srcdir/winsup.api/known_bugs.tcl"
|
||||
|
||||
if { ! [isnative] } {
|
||||
verbose "skipping winsup.api because it's not native"
|
||||
@ -6,6 +7,11 @@ if { ! [isnative] } {
|
||||
}
|
||||
|
||||
set rv ""
|
||||
set add_includes ""
|
||||
set add_libs ""
|
||||
|
||||
set ltp_includes "-I$ltp_includes"
|
||||
set ltp_libs "$rootme/libltp.a"
|
||||
|
||||
proc ws_spawn {cmd args} {
|
||||
global rv
|
||||
@ -20,24 +26,45 @@ foreach src [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.c] {
|
||||
regsub ".*/" $base "" basename
|
||||
regsub "/" $base "-" base
|
||||
|
||||
if { [regexp "^xf-" $basename] } {
|
||||
if { [lsearch -exact $xfail_list $basename] >= 0 } {
|
||||
set xfail_expected 1
|
||||
setup_xfail "*-*-*"
|
||||
} else {
|
||||
set xfail_expected 0
|
||||
clear_xfail
|
||||
}
|
||||
|
||||
ws_spawn "$CC $src $rootme/new-libcygwin.a -o $base.exe"
|
||||
if { [regexp "^ltp/" $testcase ] } {
|
||||
set add_includes $ltp_includes
|
||||
set add_libs $ltp_libs
|
||||
}
|
||||
|
||||
ws_spawn "$CC -g3 $CFLAGS $src $add_includes $add_libs $runtime_root/new-libcygwin.a -o $base.exe"
|
||||
if { $rv != "" } {
|
||||
verbose -log "$rv"
|
||||
fail "$testcase (compile)"
|
||||
} else {
|
||||
ws_spawn "../cygrun ./$base.exe > /dev/null"
|
||||
if { $verbose } {
|
||||
set redirect_output "./$base.log"
|
||||
} else {
|
||||
set redirect_output /dev/null
|
||||
}
|
||||
ws_spawn "$runtime_root/cygrun ./$base.exe > $redirect_output"
|
||||
if { $rv != "" } {
|
||||
verbose -log "$testcase: $rv"
|
||||
fail "$testcase (execute)"
|
||||
if { $xfail_expected } {
|
||||
catch { file delete "$base.exe" } err
|
||||
if { $err != "" } {
|
||||
note "error deleting $base.exe: $err"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pass "$testcase"
|
||||
file delete "$base.exe"
|
||||
catch { file delete "$base.exe" } err
|
||||
if { $err != "" } {
|
||||
note "error deleting $base.exe: $err"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user