diff options
Diffstat (limited to 'winsup/testsuite')
99 files changed, 26942 insertions, 5 deletions
diff --git a/winsup/testsuite/ChangeLog b/winsup/testsuite/ChangeLog new file mode 100644 index 000000000..569fdf2a5 --- /dev/null +++ b/winsup/testsuite/ChangeLog @@ -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 diff --git a/winsup/testsuite/Makefile.in b/winsup/testsuite/Makefile.in new file mode 100644 index 000000000..98373ff81 --- /dev/null +++ b/winsup/testsuite/Makefile.in @@ -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) + +# + diff --git a/winsup/testsuite/config/default.exp b/winsup/testsuite/config/default.exp index ec8ce1448..5bbaf8d1f 100644 --- a/winsup/testsuite/config/default.exp +++ b/winsup/testsuite/config/default.exp @@ -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 {} { diff --git a/winsup/testsuite/configure b/winsup/testsuite/configure new file mode 100644 index 000000000..c57fde2cc --- /dev/null +++ b/winsup/testsuite/configure @@ -0,0 +1,1193 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=Makefile.in + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:529: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:559: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:610: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:642: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 653 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:684: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:689: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:698: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:717: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:749: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext <<EOF +#line 764 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:770: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext <<EOF +#line 781 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:787: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext <<EOF +#line 798 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:804: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:854: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:875: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +if test $host != $build; then + ac_tool_prefix=${host_alias}- +else + ac_tool_prefix= +fi + +# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:901: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar" +fi +fi +AR="$ac_cv_prog_AR" +if test -n "$AR"; then + echo "$ac_t""$AR" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS <<EOF +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir + +trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS <<EOF + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@CC@%$CC%g +s%@CPP@%$CPP%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g +s%@AR@%$AR%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <<EOF + +CONFIG_FILES=\${CONFIG_FILES-"Makefile"} +EOF +cat >> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +EOF +cat >> $CONFIG_STATUS <<EOF + +EOF +cat >> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/winsup/testsuite/configure.in b/winsup/testsuite/configure.in new file mode 100755 index 000000000..6d198437d --- /dev/null +++ b/winsup/testsuite/configure.in @@ -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) diff --git a/winsup/testsuite/winsup.api/known_bugs.tcl b/winsup/testsuite/winsup.api/known_bugs.tcl new file mode 100644 index 000000000..c84eaad28 --- /dev/null +++ b/winsup/testsuite/winsup.api/known_bugs.tcl @@ -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] + + diff --git a/winsup/testsuite/winsup.api/ltp/access01.c b/winsup/testsuite/winsup.api/ltp/access01.c new file mode 100644 index 000000000..e108d8194 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/access01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/access03.c b/winsup/testsuite/winsup.api/ltp/access03.c new file mode 100644 index 000000000..d2c2c29f0 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/access03.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/alarm01.c b/winsup/testsuite/winsup.api/ltp/alarm01.c new file mode 100644 index 000000000..bfae190c6 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/alarm01.c @@ -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); +} + diff --git a/winsup/testsuite/winsup.api/ltp/alarm02.c b/winsup/testsuite/winsup.api/ltp/alarm02.c new file mode 100644 index 000000000..65e3c2b86 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/alarm02.c @@ -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; +} + + diff --git a/winsup/testsuite/winsup.api/ltp/alarm03.c b/winsup/testsuite/winsup.api/ltp/alarm03.c new file mode 100644 index 000000000..4948bb0b4 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/alarm03.c @@ -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); +} + diff --git a/winsup/testsuite/winsup.api/ltp/asyncio02.c b/winsup/testsuite/winsup.api/ltp/asyncio02.c new file mode 100644 index 000000000..23532da79 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/asyncio02.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/chdir02.c b/winsup/testsuite/winsup.api/ltp/chdir02.c new file mode 100644 index 000000000..3d0e4f306 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/chdir02.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/chmod02.c b/winsup/testsuite/winsup.api/ltp/chmod02.c new file mode 100644 index 000000000..6a3914518 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/chmod02.c @@ -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() */ + diff --git a/winsup/testsuite/winsup.api/ltp/chown01.c b/winsup/testsuite/winsup.api/ltp/chown01.c new file mode 100644 index 000000000..18184c279 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/chown01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/close08.c b/winsup/testsuite/winsup.api/ltp/close08.c new file mode 100644 index 000000000..8cb933221 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/close08.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/creat09.c b/winsup/testsuite/winsup.api/ltp/creat09.c new file mode 100644 index 000000000..794f66c55 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/creat09.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/dup01.c b/winsup/testsuite/winsup.api/ltp/dup01.c new file mode 100644 index 000000000..b7ed8de2b --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/dup01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/dup02.c b/winsup/testsuite/winsup.api/ltp/dup02.c new file mode 100644 index 000000000..a16cb658c --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/dup02.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/dup04.c b/winsup/testsuite/winsup.api/ltp/dup04.c new file mode 100644 index 000000000..a2a2c343a --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/dup04.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/dup05.c b/winsup/testsuite/winsup.api/ltp/dup05.c new file mode 100644 index 000000000..03314b10c --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/dup05.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/execl01.c b/winsup/testsuite/winsup.api/ltp/execl01.c new file mode 100644 index 000000000..90a3ec540 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/execl01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/execle01.c b/winsup/testsuite/winsup.api/ltp/execle01.c new file mode 100644 index 000000000..46a27a29e --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/execle01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/execlp01.c b/winsup/testsuite/winsup.api/ltp/execlp01.c new file mode 100644 index 000000000..e8e4a5332 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/execlp01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/execv01.c b/winsup/testsuite/winsup.api/ltp/execv01.c new file mode 100644 index 000000000..5f2459668 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/execv01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/execve01.c b/winsup/testsuite/winsup.api/ltp/execve01.c new file mode 100644 index 000000000..402205b49 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/execve01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/execvp01.c b/winsup/testsuite/winsup.api/ltp/execvp01.c new file mode 100644 index 000000000..d7d0cc3b9 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/execvp01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/fchmod01.c b/winsup/testsuite/winsup.api/ltp/fchmod01.c new file mode 100644 index 000000000..0e27179d8 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fchmod01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/fchown01.c b/winsup/testsuite/winsup.api/ltp/fchown01.c new file mode 100644 index 000000000..3c9340348 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fchown01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/fcntl02.c b/winsup/testsuite/winsup.api/ltp/fcntl02.c new file mode 100644 index 000000000..70f7803b7 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fcntl02.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/fcntl03.c b/winsup/testsuite/winsup.api/ltp/fcntl03.c new file mode 100644 index 000000000..be8289f5e --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fcntl03.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/fcntl04.c b/winsup/testsuite/winsup.api/ltp/fcntl04.c new file mode 100644 index 000000000..2dd1eb982 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fcntl04.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/fcntl05.c b/winsup/testsuite/winsup.api/ltp/fcntl05.c new file mode 100644 index 000000000..44180a5bc --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fcntl05.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/fcntl07.c b/winsup/testsuite/winsup.api/ltp/fcntl07.c new file mode 100644 index 000000000..3af0ec6fd --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fcntl07.c @@ -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 */ +} diff --git a/winsup/testsuite/winsup.api/ltp/fcntl07B.c b/winsup/testsuite/winsup.api/ltp/fcntl07B.c new file mode 100644 index 000000000..2d03dcabe --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fcntl07B.c @@ -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 */ +} diff --git a/winsup/testsuite/winsup.api/ltp/fcntl08.c b/winsup/testsuite/winsup.api/ltp/fcntl08.c new file mode 100644 index 000000000..b96e0c2d4 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fcntl08.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/fcntl09.c b/winsup/testsuite/winsup.api/ltp/fcntl09.c new file mode 100644 index 000000000..fe37077ad --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fcntl09.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/fcntl10.c b/winsup/testsuite/winsup.api/ltp/fcntl10.c new file mode 100644 index 000000000..96e1e12e6 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fcntl10.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/fork01.c b/winsup/testsuite/winsup.api/ltp/fork01.c new file mode 100644 index 000000000..d45d30be5 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fork01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/fork04.c b/winsup/testsuite/winsup.api/ltp/fork04.c new file mode 100644 index 000000000..9fb7a8c9f --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fork04.c @@ -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 */ diff --git a/winsup/testsuite/winsup.api/ltp/fpathconf01.c b/winsup/testsuite/winsup.api/ltp/fpathconf01.c new file mode 100644 index 000000000..2c0f1a77b --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fpathconf01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/fstat01.c b/winsup/testsuite/winsup.api/ltp/fstat01.c new file mode 100644 index 000000000..9bc9d5f64 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fstat01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/fsync01.c b/winsup/testsuite/winsup.api/ltp/fsync01.c new file mode 100644 index 000000000..1f077b7f5 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/fsync01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/getegid01.c b/winsup/testsuite/winsup.api/ltp/getegid01.c new file mode 100644 index 000000000..7bbee0fac --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/getegid01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/geteuid01.c b/winsup/testsuite/winsup.api/ltp/geteuid01.c new file mode 100644 index 000000000..90f289caa --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/geteuid01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/getgid01.c b/winsup/testsuite/winsup.api/ltp/getgid01.c new file mode 100644 index 000000000..ff146fc1f --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/getgid01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/getgroups01.c b/winsup/testsuite/winsup.api/ltp/getgroups01.c new file mode 100644 index 000000000..ab39e8613 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/getgroups01.c @@ -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() */ + diff --git a/winsup/testsuite/winsup.api/ltp/getgroups02.c b/winsup/testsuite/winsup.api/ltp/getgroups02.c new file mode 100644 index 000000000..977ae529d --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/getgroups02.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/gethostid01.c b/winsup/testsuite/winsup.api/ltp/gethostid01.c new file mode 100644 index 000000000..7d43992b2 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/gethostid01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/gethostname01.c b/winsup/testsuite/winsup.api/ltp/gethostname01.c new file mode 100644 index 000000000..2e2e52058 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/gethostname01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/getpgrp01.c b/winsup/testsuite/winsup.api/ltp/getpgrp01.c new file mode 100644 index 000000000..49c931b02 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/getpgrp01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/getpid01.c b/winsup/testsuite/winsup.api/ltp/getpid01.c new file mode 100644 index 000000000..0f1720349 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/getpid01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/getppid01.c b/winsup/testsuite/winsup.api/ltp/getppid01.c new file mode 100644 index 000000000..d001fd1f6 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/getppid01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/getuid01.c b/winsup/testsuite/winsup.api/ltp/getuid01.c new file mode 100644 index 000000000..c4d779490 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/getuid01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/kill09.c b/winsup/testsuite/winsup.api/ltp/kill09.c new file mode 100644 index 000000000..d1b1c3c58 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/kill09.c @@ -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); +} diff --git a/winsup/testsuite/winsup.api/ltp/link02.c b/winsup/testsuite/winsup.api/ltp/link02.c new file mode 100644 index 000000000..330337a8e --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/link02.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/link03.c b/winsup/testsuite/winsup.api/ltp/link03.c new file mode 100644 index 000000000..95c3a7674 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/link03.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/link04.c b/winsup/testsuite/winsup.api/ltp/link04.c new file mode 100644 index 000000000..21a5471a2 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/link04.c @@ -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; +} diff --git a/winsup/testsuite/winsup.api/ltp/link05.c b/winsup/testsuite/winsup.api/ltp/link05.c new file mode 100644 index 000000000..f2c52ae45 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/link05.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/lseek01.c b/winsup/testsuite/winsup.api/ltp/lseek01.c new file mode 100644 index 000000000..e6d70a46b --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/lseek01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/lseek02.c b/winsup/testsuite/winsup.api/ltp/lseek02.c new file mode 100644 index 000000000..bce2b954a --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/lseek02.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/lseek04.c b/winsup/testsuite/winsup.api/ltp/lseek04.c new file mode 100644 index 000000000..a79d0cf7c --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/lseek04.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/lseek05.c b/winsup/testsuite/winsup.api/ltp/lseek05.c new file mode 100644 index 000000000..669156b20 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/lseek05.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/lstat02.c b/winsup/testsuite/winsup.api/ltp/lstat02.c new file mode 100644 index 000000000..5f491be95 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/lstat02.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/mkdir01.c b/winsup/testsuite/winsup.api/ltp/mkdir01.c new file mode 100644 index 000000000..b2ed07fe0 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/mkdir01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/mkdir08.c b/winsup/testsuite/winsup.api/ltp/mkdir08.c new file mode 100644 index 000000000..515ac83c7 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/mkdir08.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/mknod01.c b/winsup/testsuite/winsup.api/ltp/mknod01.c new file mode 100644 index 000000000..f009b9dda --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/mknod01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/nice05.c b/winsup/testsuite/winsup.api/ltp/nice05.c new file mode 100644 index 000000000..77135d451 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/nice05.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/open03.c b/winsup/testsuite/winsup.api/ltp/open03.c new file mode 100644 index 000000000..312093ba4 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/open03.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/pathconf01.c b/winsup/testsuite/winsup.api/ltp/pathconf01.c new file mode 100644 index 000000000..fce0c041f --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/pathconf01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/pause01.c b/winsup/testsuite/winsup.api/ltp/pause01.c new file mode 100644 index 000000000..109445646 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/pause01.c @@ -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() +{ +} diff --git a/winsup/testsuite/winsup.api/ltp/readlink02.c b/winsup/testsuite/winsup.api/ltp/readlink02.c new file mode 100644 index 000000000..8bd37a4ed --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/readlink02.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/rename02.c b/winsup/testsuite/winsup.api/ltp/rename02.c new file mode 100644 index 000000000..f2390e8bf --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/rename02.c @@ -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)); + +} diff --git a/winsup/testsuite/winsup.api/ltp/rmdir04.c b/winsup/testsuite/winsup.api/ltp/rmdir04.c new file mode 100644 index 000000000..304f37d25 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/rmdir04.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/select01.c b/winsup/testsuite/winsup.api/ltp/select01.c new file mode 100644 index 000000000..69bb8cd63 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/select01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/setgid01.c b/winsup/testsuite/winsup.api/ltp/setgid01.c new file mode 100644 index 000000000..d05db1801 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/setgid01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/setgroups01.c b/winsup/testsuite/winsup.api/ltp/setgroups01.c new file mode 100644 index 000000000..dfdb6b763 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/setgroups01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/setpgid01.c b/winsup/testsuite/winsup.api/ltp/setpgid01.c new file mode 100644 index 000000000..8e26e0999 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/setpgid01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/setregid01.c b/winsup/testsuite/winsup.api/ltp/setregid01.c new file mode 100644 index 000000000..ff30f9c39 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/setregid01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/setreuid01.c b/winsup/testsuite/winsup.api/ltp/setreuid01.c new file mode 100644 index 000000000..ce86a2c07 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/setreuid01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/setuid01.c b/winsup/testsuite/winsup.api/ltp/setuid01.c new file mode 100644 index 000000000..75b6b8902 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/setuid01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/setuid02.c b/winsup/testsuite/winsup.api/ltp/setuid02.c new file mode 100644 index 000000000..11b19588b --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/setuid02.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/stat05.c b/winsup/testsuite/winsup.api/ltp/stat05.c new file mode 100644 index 000000000..52652536e --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/stat05.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/symlink01.c b/winsup/testsuite/winsup.api/ltp/symlink01.c new file mode 100644 index 000000000..f202ee2bc --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/symlink01.c @@ -0,0 +1,2024 @@ +/* + * 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 : symlink01 (symlink) +* +* TEST TITLE : Make a Symbolic Link to a File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 5 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : readlink01 (readlink) +* +* TEST TITLE : Reads Value of a Symbolic Link +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 4 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : stat04 (stat) +* +* TEST TITLE : Gets File Status Indirectly From a Symbolic Link +* File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 3 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : lstat01 (lstat) +* +* TEST TITLE : Get file Status About a Symbolic Link File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 3 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : mkdir05 (mkdir) +* +* TEST TITLE : Fail When Making a Directory File Indirectly From +* a Symbolic Link File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 1 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : rmdir03 (rmdir) +* +* TEST TITLE : Fail When Removing a Directory File Indirectly +* From a Symbolic Link File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 1 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : chdir01 (chdir) +* +* TEST TITLE : Changes Current Working DIrectory Location +* Indirectly From a Symbolic Link File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 3 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : link01 (link) +* +* TEST TITLE : Creates a Link To a File Indirectly From a +* Symbolic Link File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 3 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : unlink01 (unlink) +* +* TEST TITLE : Removes a Link To a File And Not Any Object File +* Which Maybe Pointed At +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 1 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : chmod01 (chmod) +* +* TEST TITLE : Change Object File Permissions Indirectly From a +* Symbolic Link File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 3 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : utime01 (utime) +* +* TEST TITLE : Set File Access And Modify Object File Times +* Indirectly From a Symbolic Link File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 3 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : rename01 (rename) +* +* TEST TITLE : Rename a Symbolic Link File And Not Any Object +* File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 3 +* +* WALL CLOCK TIME : 3 +* +* TEST IDENTIFIER : open01 (open) +* +* TEST TITLE : Create/Open a File For Reading Or Writing +* Indirectly From a Symbolic Link File +* +* PARENT DOCUMENT : symtds01 +* +* TEST CASE TOTAL : 5 +* +* WALL CLOCK TIME : 3 +* +* EXECUTED BY : whom ever +* +* CPU TYPES : ALL +* +* AUTHOR : David Fenner +* +* CO-PILOT : Jon Hendrickson +* +* DATE STARTED : 07/25/90 +* +* INITIAL RELEASE : UNICOS 6.0 +* +* TEST CASES +* +* For symlink +* +* 1. Create symbolic link with abnormal object name path +* 2. Create symbolic link with normal object name path +* 3. Create symbolic link with path to an existing object file +* 4. Receive EEXIST error when creating an already existing symbolic link file. +* 5. Receive ENAMETOOLONG error when creating symbolic link which exceeds PATH_MAX in length +* +* For readlink +* +* 1. Read a symbolic link file which points at no object file +* 2. Read a symbolic link file which points at an object file +* 3. Receive ENAMETOOLONG error when reading symbolic link which exceeds PATH_MAX in length +* 4. Receive an EINVAL error when reading a file which is not a symbolic +* link file. +* +* For stat +* +* 1. Get object file status through symbolic link file +* 2. Receive ENOENT error when accessing non-existent object file through symbolic link file +* 3. Receive ELOOP error when nesting of symbolic links exceed maximum +* +* For lstat +* +* 1. Get symbolic link file status when pointing at no object file +* 2. Get symbolic link file status when pointing at an object file +* 3. Get object file status when argument is not a symbolic link +* file. +* +* For mkdir +* +* 1. Receive EEXIST error when creating a directory through a symbolic link file +* +* For rmdir +* +* 1. Receive ENOTDIR error when removing an existing directory through a symbolic link file +* +* For chdir +* +* 1. Change current working directory through a symbolic link file +* 2. Receive ENOENT error when accessing non-existent directory through symbolic link file +* 3. Receive ELOOP error when nesting of symbolic links exceed maximum +* +* For link +* +* 1. Link an object file to a new file through symbolic link file +* 2. Receive ENOENT error when accessing non-existent object file through symbolic link file +* 3. Receive ELOOP error when nesting of symbolic links exceed maximum +* +* For unlink +* +* 1. Delete a symbolic link file and not the object file which it points at +* +* For chmod +* +* 1. Change file permissions of object file through a symbolic link file +* 2. Receive ENOENT error when accessing non-existent directory through symbolic link file +* 3. Receive ELOOP error when nesting of symbolic links exceed maximum +* +* For utime +* +* 1. Change inode times of object file through a symbolic link file +* 2. Receive ENOENT error when accessing non-existent directory through symbolic link file +* 3. Receive ELOOP error when nesting of symbolic links exceed maximum +* +* For rename +* +* 1. Rename a symbolic link file which points at no object file +* 2. Rename a symbolic link file which points at an object file without any object file alterations. +* 3. Receive EXDEV when trying to rename a symbolic link file to an address outside of current file system +* +* For open +* +* 1. Create an object file through a symbolic link file +* 2. Open an object file through a symbolic link file +* 3. Receive EEXIST error when exclusively creating an object file through a symbolic link file +* 4. Receive ENOENT error when accessing non-existent object file through symbolic link file +* 5. Receive ELOOP error when nesting of symbolic links exceed maximum +* +* ENVIRONMENTAL NEEDS +* None +* +* DETAILED DESCRIPTION +* +* Self-documenting code so see below +* +*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ + +#include <stdio.h> +#include <signal.h> +#include <string.h> +#include <fcntl.h> /* open(2) system call */ +#include <errno.h> +#include <sys/types.h> +#include <utime.h> /* utime(2) system call */ +#include <sys/param.h> +#include <sys/stat.h> /* stat(2) and lstat(2) system calls */ + +#include "test.h" +#include "usctest.h" + +void setup(); +void cleanup(); +void help(); +void delete_files(); +void do_EEXIST(); +void do_ENOENT(); +void do_ELOOP(); +void do_ENOTDIR(); +void do_EXDEV(); +void do_ENAMETOOLONG(); +void do_EINVAL(); +void do_readlink(); +void do_stat(); +void do_chdir(); +void do_link(); +void do_unlink(); +void do_chmod(); +void do_utime(); +void do_rename(); +void do_open(); + +#define S_FILE "symbolic" /* Name of symbolic link file */ +#define O_FILE "object" /* Name of object file */ +#define A_S_FILE "asymbolic" /* Another name for a symbolic link file */ +#define Y_A_S_FILE "/NiCkEr" /* Yet another symbolic link file */ +#define BIG_STRING "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" + +#define DEFAULT_TCID "symlink01" + +#define SYMLINK "symlink01" +#define READLINK "readlink01" +#define STAT "stat04" +#define LSTAT "lstat01" +#define MKDIR "mkdir05" +#define RMDIR "rmdir03" +#define CHDIR "chdir01" +#define LINK "link01" +#define UNLINK "unlink01" +#define CHMOD "chmod01" +#define UTIME "utime01" +#define RENAME "rename01" +#define OPEN "open01" + +#define cktcsid(s1,s2) (!strcmp(s1,s2)) +#define BUFMAX 512 +#define MODE 0700 +#define MASK 0100777 /* A regular file with r,w,x for all mask */ + +/* + * Lets be optimistic and only define messages for passing test cases + */ +char *msgs[] = { + "Creation of symbolic link file to no object file is ok", + "Creation of symbolic link file and object file via symbolic link is ok", + "Creating an existing symbolic link file error is caught", + "Creating a symbolic link which exceeds maximum pathname error is caught", + "Reading of symbolic link file contents checks out ok", + "Reading a symbolic link which exceeds maximum pathname error is caught", + "Getting stat info about object file through symbolic link file is ok", + "Stat(2) error when accessing non-existent object through symbolic link is caught", + "lstat(2) of symbolic link file which points to no object file is ok", + "lstat(2) of symbolic link file which points at an object file is ok", + "mkdir(2) of object file through symbolic link file failed as expected", + "rmdir(2) of object file through symbolic link file failed as expected", + "chdir(2) to object file location through symbolic link file is ok", + "chdir(2) to non-existent object file location through symbolic link file failed as expected", + "link(2) to a symbolic link, which is pointing to an existing object file worked - file created and link count adjusted", + "link(2) to a symbolic link, which is pointing to a non-existing object file worked ok - file created and link count adjusted.", + "unlink(2) of symbolic link file with no object file removal is ok", + "chmod(2) of object file permissions through symbolic link file is ok", + "chmod(2) error when accessing non-existent object through symbolic link is caught", + "utime(2) change of object file access and modify times through symbolic link file is ok", + "utime(2) error when accessing non-existent object through symbolic link is caught", + "rename(3) of symbolic link file name which points at no object file is ok", + "rename(3) of symbolic link file name which points at object file is ok", + "rename(3) error of symbolic link file name across file systems is caught", + "open(2) with (O_CREAT | O_RDWR) to create object file through symbolic link file and all writes, reads, and lseeks are ok", + "open(2) with O_RDWR of existing object file through symbolic link file and all writes, reads, and lseeks are ok", + "open(2) with (O_CREAT | O_EXCL) error is caught when creating object file through symbolic link file", + "open(2) error with O_RDWR is caught when processing symbolic link file which points at no object file", + "Nested symbolic link access condition caught. ELOOP is returned", + "Reading a nonsymbolic link file error condition is caught. EINVAL is returned", + "lstat(2) of object file returns object file inode information", + "NULL" +}; + +/* + * Define test object setup and validation functions + */ +int creat_both(), creat_symlink(), creat_path_max(), ck_symlink(), + creat_object(), ck_object(), ck_both(), ck_path_max(); + + +/* + * Define test cases + */ +struct all_test_cases +{ + char *tcid; + int test_fail; + int errno_val; + int pass_msg; + int (*test_setup)(); + int (*ck_test)(); + char *fn_arg[3]; + +} test_objects[] = { + {SYMLINK, 0, 0, 0, creat_symlink, ck_symlink, {"%bc+eFhi!k", S_FILE, NULL}}, + {SYMLINK, 0, 0, 0, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {SYMLINK, 0, 0, 1, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {SYMLINK, 1, EEXIST, 2, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {SYMLINK, 1, ENAMETOOLONG, 3, creat_path_max, ck_path_max, {O_FILE, S_FILE, NULL}}, + {READLINK, 0, 0, 4, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {READLINK, 0, 0, 4, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {READLINK, 1, ENAMETOOLONG, 5, creat_path_max, ck_path_max, {O_FILE, S_FILE, NULL}}, + {READLINK, 1, EINVAL, 29, creat_object, ck_object, {O_FILE, NULL, NULL}}, + {STAT, 0, 0, 6, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {STAT, 1, ENOENT, 7, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {STAT, 1, ELOOP, 28, creat_symlink, ck_symlink, {S_FILE, S_FILE, NULL}}, + {LSTAT, 0, 0, 8, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {LSTAT, 0, 0, 9, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {LSTAT, 0, 0, 30, creat_object, ck_object, {O_FILE, NULL, NULL}}, + {MKDIR, 1, EEXIST, 10, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {RMDIR, 1, ENOTDIR, 11, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {CHDIR, 0, 0, 12, creat_symlink, ck_symlink, {O_FILE, S_FILE, O_FILE}}, + {CHDIR, 1, ENOENT, 13, creat_symlink, ck_symlink, {"%bc+eFhi!k", S_FILE, NULL}}, + {CHDIR, 1, ELOOP, 28, creat_symlink, ck_symlink, {S_FILE, S_FILE, NULL}}, + {LINK, 0, 0, 14, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {LINK, 0, 0, 15, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + /* The following link test case is invalid - leaving it defined so */ + /* I don't have to change all the entries in the all_tcses array after link */ + {LINK, 1, -1, -1, creat_symlink, ck_symlink, {NULL, NULL, NULL}}, + {UNLINK, 0, 0, 16, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {CHMOD, 0, 0, 17, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {CHMOD, 1, ENOENT, 18, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {CHMOD, 1, ELOOP, 28, creat_symlink, ck_symlink, {S_FILE, S_FILE, NULL}}, + {UTIME, 0, 0, 19, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {UTIME, 1, ENOENT, 20, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {UTIME, 1, ELOOP, 28, creat_symlink, ck_symlink, {S_FILE, S_FILE, NULL}}, + {RENAME, 0, 0, 21, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {RENAME, 0, 0, 22, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {RENAME, 1, EXDEV, 23, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {OPEN, 0, 0, 24, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {OPEN, 0, 0, 25, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}}, + {OPEN, 1, EEXIST, 26, creat_symlink, ck_symlink, {O_FILE, S_FILE, O_FILE}}, + {OPEN, 1, ENOENT, 27, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}}, + {OPEN, 1, ELOOP, 28, creat_symlink, ck_symlink, {S_FILE, S_FILE, NULL}} +}; + +/* + * Define tcses + */ +struct tcses +{ + char *tcid; + char *syscall; + int test_cases; /* number of entries in test_objects array */ + struct all_test_cases *tc_ptr; + char *desc; +} all_tcses[] = { + + { SYMLINK, "symlink", 5, &test_objects[0], + "Make a Symbolic Link to a File" }, + { READLINK, "readlink", 4, &test_objects[5], + "Reads Value of a Symbolic Link" }, + { STAT, "stat", 3, &test_objects[9], + "Gets File Status Indirectly From a Symbolic Link file" }, + { LSTAT, "lstat", 3, &test_objects[12], + "Get file Status About a Symbolic Link File" }, + { MKDIR, "mkdir", 1, &test_objects[15], + "Fail When Making a Directory File Indirectly from a symlink" }, + { RMDIR, "rmdir", 1, &test_objects[16], + "Fail When Removing a Directory File Indirectly from a symlink" }, + { CHDIR, "chdir", 3, &test_objects[17], + "Changes CWD Location Indirectly from a symlink" }, + { LINK, "link", 2, &test_objects[20], + "Creates a Link To a File Indirectly From a Symbolic" }, + { UNLINK, "unlink", 1, &test_objects[23], + "Removes a Link To a File but not the Object File" }, + { CHMOD, "chmod", 3, &test_objects[24], + "Change Object File Permissions Indirectly From a Symbolic" }, + { UTIME, "utime", 3, &test_objects[27], + "Set File Access And Modify Object File Times via symlink" }, + { RENAME, "rename", 3, &test_objects[30], + "Rename a Symbolic Link File And Not Any Object file" }, + { OPEN, "open", 5, &test_objects[33], + "Create/Open a File For Reading Or Writing via symlink" }, +}; + +/* + * Define GLOBAL variables + */ + +int TST_TOTAL; +int TEST_RESULT; +time_t a_time_value = 100; +char *TCID; +char *Selectedtests = NULL; /* Name (tcid) of selected test cases */ +char test_msg[BUFMAX]; +char full_path[PATH_MAX+1]; +extern int Tst_count; +extern char *TESTDIR; +extern char *strrchr(); +extern int errno; + +struct stat asymlink, statter; +char Buffer[1024]; +char Buf[1024]; + +char *Tcid = NULL; + +option_t Options[] = { + { "T:", NULL, &Tcid }, /* -T tcid option */ + { NULL, NULL, NULL } +}; + +/*********************************************************************** + * MAIN + ***********************************************************************/ +int +main(int argc, char *argv[]) +{ + struct tcses *tcs_ptr, *get_tcs_info(); + int do_syscalltests(); + void cleanup(); + int lc; /* loop counter */ + char *msg; /* message returned from parse_opts */ + + + /*************************************************************** + * parse standard options, and exit if there is an error + ***************************************************************/ + if ( (msg=parse_opts(argc, argv, Options, &help)) != (char *) NULL ) { + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); + tst_exit(); + } + + /* + * If the -T option was used, use that TCID or use the default + */ + if ( Tcid != NULL ) { + TCID = Tcid; + Selectedtests=Tcid; + + } +#ifndef ALL + else { + TCID = DEFAULT_TCID; + Selectedtests = DEFAULT_TCID; + } +#endif + + /* + * Get test case specification information and assign TST_TOTAL + */ + if ((tcs_ptr=get_tcs_info(Selectedtests)) == NULL) { + TST_TOTAL=1; + tst_brkm(TBROK, cleanup, + "Unknown symbolic link test case specification executed"); + } + + /*************************************************************** + * 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; + + /* + * Execute tcs testing function and all defined test cases + */ + do_syscalltests(tcs_ptr); + + } /* End for TEST_LOOPING */ + + /* + * End appropriately + */ + cleanup(); + + return 0; +} + +/*********************************************************************** + * This function maps the name of the process to a test case specification + * defined in the all_tcses array of tcses structures. Either a pointer + * to the mapped test case specification information is returned or a + * null pointer. + * + * Argument is path to program name. + ***********************************************************************/ +struct tcses *get_tcs_info(ptr) +char *ptr; +{ + int ctr; + struct tcses *tcs_ptr; + +#if ALL + if ( ptr == NULL ) { + + TST_TOTAL=0; + for (ctr=1; ctr < sizeof(all_tcses)/sizeof(struct tcses); ctr++) + TST_TOTAL += all_tcses[ctr].test_cases; + return all_tcses; + } +#endif + + + for(ctr=0; ctr < (sizeof(all_tcses)/sizeof(struct tcses)); ctr++) { + if ( strcmp(ptr, all_tcses[ctr].tcid) == 0 || + strcmp(ptr, all_tcses[ctr].syscall) == 0 ) { + tcs_ptr = &all_tcses[ctr]; + TCID = all_tcses[ctr].tcid; + TST_TOTAL=tcs_ptr->test_cases; + return(tcs_ptr); + } + + } + return(NULL); +} + +/*********************************************************************** + * Determines if what path points at is a symbolic link file + * + * Argument is path to symbolic link file. + * + * Return status is one if a symbolic link file. Zero if not a symbolic + * link file and a minus one if the path doesn't point at a file. + ***********************************************************************/ +int +see_if_a_symlink(path) +char *path; +{ + if (lstat(path, &asymlink) < 0) + return(-1); + + if ((asymlink.st_mode & S_IFMT) == S_IFLNK) + return(1); + else + return(0); +} + +/*********************************************************************** + * This function performs without any hesitation, file(s) deletions + ***********************************************************************/ +void +delete_files(path1, path2) +char *path1, *path2; +{ + unlink(path1); + unlink(path2); +} + +/*********************************************************************** + * + * This routine creates a symbolic link file. + * + * Argument one is symbolic link pathname to point at. + * Argument two is name of symbolic link file. + * + ***********************************************************************/ +int +creat_symlink(path1, path2) +char *path1, *path2; +{ + TEST( symlink(path1, path2) ); + errno=TEST_ERRNO; + if (TEST_RETURN == -1) { + TEST_RESULT=TBROK; + sprintf(test_msg, + "symlink(2) Failure when creating setup %s object file: errno:%d %s", + path1, errno, strerror(errno)); + return(0); + } + else { + sprintf(Buf, "symlink(%s, %s) was succesful.\n", path1, path2); + strcat(Buffer, Buf); +#if DEBUG + tst_resm(TPASS, "symlink(%s, %s) was succesful.", path1, path2); +#endif + } + return(1); +} + +/*********************************************************************** + * + * This routine creates a regular file. + * + * Argument one is a pathname + * + ***********************************************************************/ +int +creat_object(path1) +char *path1; +{ + int fd; + if ((fd=creat(path1, MODE)) == -1) { + TEST_RESULT=TBROK; + sprintf(test_msg, + "creat(2) Failure when creating setup %s object file: errno:%d %s", + path1, errno, strerror(errno)); + return(0); + } + else { + sprintf(Buf, "creat(%s, %#o) was succesful.\n", path1, MODE); + strcat(Buffer, Buf); +#if DEBUG + tst_resm(TPASS, "creat(%s, %#o) was succesful.", path1, MODE); +#endif + } + if (close(fd) == -1) { + TEST_RESULT=TBROK; + sprintf(test_msg, + "close(2) Failure when closing setup %s object file: errno:%d %s", + path1, errno, strerror(errno)); + return(0); + } + return(1); +} + +/*********************************************************************** + * + * This routine creates a symbolic link file and a regular file. + * + * Argument one is a pathname of object file + * Argument two is symbolic link file name + * Argument three is regular file name + * + ***********************************************************************/ +int +creat_both(path1, path2, path3) +char *path1, *path2, *path3; +{ + if (creat_symlink(path1, path2) == -1) + return(0); + else if (creat_object(path3) == -1) + return(0); + return(1); +} + +/*********************************************************************** + * + * This routine checks if symbolic link file is a symbolic link file. + * + * Argument one is a pathname of object file + * Argument two is symbolic link file name + * Argument three is regular file name + * + ***********************************************************************/ +int +ck_symlink(path1, path2, path3) +char *path1, *path2, *path3; +{ + int ret; + + if ((ret=see_if_a_symlink(path2)) == -1) { + TEST_RESULT=TBROK; + sprintf(test_msg, + "lstat(2) Failure when accessing %s symbolic link file which should contain %s path to %s file ", + path2, path1, path3); + return(0); + } + else if (ret == 0) { + TEST_RESULT=TBROK; + sprintf(test_msg, + "%s is not a symbolic link file which contains %s path to %s file", + path2, path1, path3); + return(0); + } + return(1); +} + +/*********************************************************************** + * + * This routine checks if symbolic link file points at object file. + * + * Argument one is a pathname of object file + * Argument two is symbolic link file name + * Argument three is regular file name + * + ***********************************************************************/ +int +ck_both(path1, path2, path3) +char *path1, *path2, *path3; +{ + if (ck_symlink(path1, path2, path3) == 0) + return(0); + else if ((stat(path3, &statter) == -1) && (errno == ENOENT)) { + TEST_RESULT=TBROK; + sprintf(test_msg, "stat(2) Failure when accessing %s object file ", path3); + return(0); + } + else if ((stat(path2, &asymlink) == -1) && (errno == ENOENT)) { + TEST_RESULT=TBROK; + sprintf(test_msg, "stat(2) Failure when accessing %s symbolic link file ", + path2); + return(0); + } + else if (statter.st_ino != asymlink.st_ino) { + TEST_RESULT=TBROK; + sprintf(test_msg, + "stat(2) Failure when accessing %s object file through %s symbolic link file ", + path3, path2); + return(0); + } + return(1); + +} + +/*********************************************************************** + * This routine populates full_path with a pathname whose length exceeds + * the PATH_MAX define value in param.h + * + * Argument one is a pathname of object file + * Argument two is symbolic link file name + * Argument three is regular file name + ***********************************************************************/ +int +creat_path_max(path1, path2, path3) +char *path1, *path2, *path3; +{ + int ctr, to_go, size, whole_chunks; + char *cwd, *getcwd(); + + if ((cwd = getcwd((char *)NULL, 64)) == NULL) + { + TEST_RESULT=TBROK; + sprintf(test_msg, + "getcwd(3) Failure in setup of %s %s %s test case object elements", + path1, path2, path3); + return(0); + } + cwd = getcwd((char *)NULL, 64); + size = strlen(cwd); + + to_go = PATH_MAX - size; + size = strlen(path1); + whole_chunks = to_go / size; + strcpy(full_path, cwd); + for (ctr=0; ctr < whole_chunks; ctr++) { + strcat(full_path, path1); + } + size= strlen(full_path); + to_go = PATH_MAX - size; + strcat(full_path, "/"); + for (ctr=0; ctr < to_go; ctr++) + strcat(full_path, "Z"); + + return(1); +} + +/*********************************************************************** + * This routine checks that full_path's length exceeds the PATH_MAX + * define value in param.h + * + * Argument one is a pathname of object file + * Argument two is symbolic link file name + * Argument three is regular file name + ***********************************************************************/ +int +ck_path_max(path1, path2, path3) +char *path1, *path2, *path3; +{ + if (strlen(full_path) == (PATH_MAX+1)) + return(1); + else + { + TEST_RESULT=TBROK; + sprintf(test_msg, "%s %d %s %s %s %s", + "full_path character array length was not", (PATH_MAX+1), + "characters long for test case object elements", + path1, path2, path3); + return(0); + } +} + +/*********************************************************************** + * This routine checks if the stat(2) and lstat(2) calls return the same + * information when the path is not a symbolic link file + * + * Argument one is a pathname of object file + * Argument two is symbolic link file name + * Argument three is regular file name + * + ***********************************************************************/ +int +ck_object(path1, path2, path3) +char *path1, *path2, *path3; +{ + int ret; + + if ((ret=see_if_a_symlink(path1)) < 0) { + TEST_RESULT=TFAIL; + sprintf(test_msg, + "lstat(2) failed to return inode information for a regular object file"); + return(0); + } + else if (ret == 1) { + TEST_RESULT=TFAIL; + sprintf(test_msg, + "lstat(2) detected a regular object file as a symbolic link file"); + return(0); + } + else if (stat(path1, &statter) == -1) { + TEST_RESULT=TBROK; + sprintf(test_msg, + "stat(2) failed to return inode information for a regular object file"); + return(0); + } + else if (bcmp((char *)&statter, (char *)&asymlink, sizeof(statter)) != 0) { + TEST_RESULT=TFAIL; + sprintf(test_msg, + "lstat(2) and stat(2) do not return same inode information for an object file"); + return(0); + + } + return(1); +} + +/*********************************************************************** + * Main test case processing function + * + * Argument is a ptr into the all_tcses array of structures of type tcses + ***********************************************************************/ +int +do_syscalltests(tcs) +struct tcses *tcs; +{ + int ctr, ret; + struct all_test_cases *tc_ptr; + + /* + * loop through desired number of test cases + */ + for (ctr=0, tc_ptr=tcs->tc_ptr; ctr < TST_TOTAL; ctr++, tc_ptr++) { + + Buffer[0]='\0'; + + /* + * If running all test cases for all tcid, set the TCID if needed. + */ + if ( Selectedtests == NULL ) { + if ( strcmp(tcs->tcid, tc_ptr->tcid) != 0 ) { + TCID = tc_ptr->tcid; + Tst_count=0; + } + } + /* + * Insure that we are executing the correct tcs test case + */ + if (strcmp(tcs->tcid, tc_ptr->tcid) != 0) { + tst_resm(TBROK, "%s TCID attempted to execute %s %d %d test case", + tcs->tcid, tc_ptr->tcid, tc_ptr->test_fail, tc_ptr->errno_val); + continue; + } + TEST_RESULT=TPASS; + delete_files(S_FILE, O_FILE); + /* + * Perform test case setup + */ + ret = (tc_ptr->test_setup)(tc_ptr->fn_arg[0], tc_ptr->fn_arg[1], + tc_ptr->fn_arg[2], tc_ptr->errno_val); + + /* If an expected error, try it out */ + + if (tc_ptr->test_fail) { + /* + * Try to perform test verification function + */ + if (! (tc_ptr->ck_test)(tc_ptr->fn_arg[0], tc_ptr->fn_arg[1], + tc_ptr->fn_arg[2], tc_ptr->errno_val)) + tst_resm(TEST_RESULT, test_msg); + else if (tc_ptr->errno_val == EEXIST) + do_EEXIST(tc_ptr); + else if (tc_ptr->errno_val == ENOENT) + do_ENOENT(tc_ptr); + else if (tc_ptr->errno_val == ELOOP) + do_ELOOP(tc_ptr); + else if (tc_ptr->errno_val == ENOTDIR) + do_ENOTDIR(tc_ptr); + else if (tc_ptr->errno_val == EXDEV) + do_EXDEV(tc_ptr); + else if (tc_ptr->errno_val == ENAMETOOLONG) + do_ENAMETOOLONG(tc_ptr); + else if (tc_ptr->errno_val == EINVAL) + do_EINVAL(tc_ptr); + else + tst_resm(TBROK, "Test Case Declaration Error"); + } + else if (ret == 1) { /* No setup function error */ + + if (tc_ptr->errno_val != 0) + tst_resm(TBROK, "Test Case Declaration Error"); + else { + /* + * Perform test verification function + */ + ret=(tc_ptr->ck_test)(tc_ptr->fn_arg[0], tc_ptr->fn_arg[1], + tc_ptr->fn_arg[2], tc_ptr->errno_val); + + /* Perform requested symbolic link system call test */ + + if ((cktcsid(tc_ptr->tcid, SYMLINK)) || + (cktcsid(tc_ptr->tcid, LSTAT))) { + if (ret == 1) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + tst_resm(TEST_RESULT, test_msg); + } + else if (ret == 0) + tst_resm(TEST_RESULT, test_msg); + else if (cktcsid(tc_ptr->tcid, READLINK)) + do_readlink(tc_ptr); + else if (cktcsid(tc_ptr->tcid, STAT)) + do_stat(tc_ptr); + else if (cktcsid(tc_ptr->tcid, CHDIR)) + do_chdir(tc_ptr); + else if (cktcsid(tc_ptr->tcid, LINK)) + do_link(tc_ptr); + else if (cktcsid(tc_ptr->tcid, UNLINK)) + do_unlink(tc_ptr); + else if (cktcsid(tc_ptr->tcid, CHMOD)) + do_chmod(tc_ptr); + else if (cktcsid(tc_ptr->tcid, UTIME)) + do_utime(tc_ptr); + else if (cktcsid(tc_ptr->tcid, RENAME)) + do_rename(tc_ptr); + else if (cktcsid(tc_ptr->tcid, OPEN)) + do_open(tc_ptr); + else + tst_resm(TBROK, "Unknown test case processing actions declared"); + } + } + else + tst_resm(TBROK, "Test Case Declaration Error"); + } + return(0); +} + +/*********************************************************************** + * This routine checks for the return of EEXIST errno from requested + * system call + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_EEXIST(tc_ptr) +struct all_test_cases *tc_ptr; +{ + if (cktcsid(tc_ptr->tcid, SYMLINK)) { + + TEST( symlink(tc_ptr->fn_arg[0], tc_ptr->fn_arg[1]) ); + errno=TEST_ERRNO; + if ((TEST_RETURN == -1) && (errno == EEXIST)) + if ( STD_FUNCTIONAL_TEST ) + tst_resm(TPASS, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s %s", + "Expected EEXIST error when creating a symbolic link file", + "which already existed"); + } + else if (cktcsid(tc_ptr->tcid, MKDIR)) { + + TEST ( mkdir(tc_ptr->fn_arg[1],MODE) ); + errno=TEST_ERRNO; + if ((TEST_RETURN == -1) && (errno == EEXIST)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else { + + tst_resm(TFAIL, "%s %s", + "Expected EEXIST error when creating a directory by a symbolic", + "link file which pointed at no object file"); + rmdir(tc_ptr->fn_arg[1]); + } + } + else if (cktcsid(tc_ptr->tcid, OPEN)) { + + TEST( open(tc_ptr->fn_arg[1], (O_EXCL | O_CREAT)) ) + errno=TEST_ERRNO; + if ((TEST_RETURN == -1) && (errno == EEXIST)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s %s errno:%d %s", + "Expected EEXIST error for exclusively opening an object file", + "through a symbolic link file was not received:", + errno, strerror(errno)); + } + else + tst_resm(TBROK, "Unknown test case processing actions declared"); +} + +/*********************************************************************** + * This routine checks for the return of ENOENT errno from requested + * system call + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_ENOENT(tc_ptr) +struct all_test_cases *tc_ptr; +{ + if (cktcsid(tc_ptr->tcid, STAT)) { + + if ((stat(tc_ptr->fn_arg[1], &asymlink) == -1) && (errno == ENOENT)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s %s errno:%d %s", + "Expected ENOENT error for stating a non-existent directory", + "through a symbolic link file was not received:", + errno, strerror(errno)); + } + else if (cktcsid(tc_ptr->tcid, CHDIR)) { + if ((chdir(tc_ptr->fn_arg[1]) == -1) && (errno == ENOENT)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else { + tst_resm(TFAIL, "%s %s errno:%d %s", + "Expected ENOENT error for changing to a non-existent", + "directory through a symbolic link file was not received:", + errno, strerror(errno)); + chdir(TESTDIR); + } + } + else if (cktcsid(tc_ptr->tcid, LINK)) { + + if ((link(tc_ptr->fn_arg[1], "nick") == -1) && (errno == ENOENT)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + { + tst_resm(TFAIL, "%s %s errno:%d %s", + "Expected ENOENT error condition when link(2) a symbolic", + "link which pointed at no object:", errno, strerror(errno)); + delete_files("nick", NULL); + } + } + else if (cktcsid(tc_ptr->tcid, CHMOD)) { + + if ((chmod(tc_ptr->fn_arg[1], MODE) == -1) && (errno == ENOENT)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s %s errno:%d %s", + "Expected ENOENT error condition when chmod(2) a symbolic", + "link which pointed at no object,", errno, strerror(errno)); + } + else if (cktcsid(tc_ptr->tcid, UTIME)) { + + if ((utime(tc_ptr->fn_arg[1], NULL) == -1) && (errno == ENOENT)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s %s errno:%d %s", + "Expected ENOENT error condition when utime(2) a symbolic", + "link which pointed at no object:", errno, strerror(errno)); + } + else if (cktcsid(tc_ptr->tcid, OPEN)) { + + if ((open(tc_ptr->fn_arg[1], O_RDWR) == -1) && (errno == ENOENT)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s %s errno:%d %s", + "Expected ENOENT error for opening a non-existent object", + " file through a symbolic link file was not received,", + errno, strerror(errno)); + } + else + tst_resm(TBROK, "Unknown test case processing actions declared"); +} + +/*********************************************************************** + * This routine checks for the return of ELOOP errno from requested + * system call + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_ELOOP(tc_ptr) +struct all_test_cases *tc_ptr; +{ + if (cktcsid(tc_ptr->tcid, STAT)) { + + TEST( stat(tc_ptr->fn_arg[1], &asymlink) ); + errno=TEST_ERRNO; + if ((TEST_RETURN == -1) && (errno == ELOOP)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, "%s errno:%d %s", + "Expected ELOOP errno from stat(2) (nested symb link),", + errno, strerror(errno)); + else + Tst_count++; + } + else if (cktcsid(tc_ptr->tcid, CHDIR)) { + + TEST( chdir(tc_ptr->fn_arg[1]) ); + errno=TEST_ERRNO; + if ((TEST_RETURN == -1) && (errno == ELOOP)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else { + + tst_resm(TFAIL, "%s errno:%d %s", + "Expected ELOOP error condition when chdir(2) a nested symbolic link:", + errno, strerror(errno)); + chdir(TESTDIR); + } + } + else if (cktcsid(tc_ptr->tcid, LINK)) { + + TEST ( link(tc_ptr->fn_arg[1], O_FILE) ); + errno=TEST_ERRNO; + if ((TEST_RETURN == -1) && (errno == ELOOP)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s errno:%d %s", + "Expected ELOOP error condition when link(2) a nested symbolic link:", + errno, strerror(errno)); + } + else if (cktcsid(tc_ptr->tcid, CHMOD)) { + + TEST ( chmod(tc_ptr->fn_arg[1], MODE) ); + errno=TEST_ERRNO; + if ((TEST_RETURN == -1) && (errno == ELOOP)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s errno:%d %s", + "Expected ELOOP error condition when chmod(2) a nested symbolic link:", + errno, strerror(errno)); + return; + } + else if (cktcsid(tc_ptr->tcid, UTIME)) { + + TEST( utime(tc_ptr->fn_arg[1], NULL) ); + errno=TEST_ERRNO; + + if ((TEST_RETURN == -1) && (errno == ELOOP)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s errno:%d %s", + "Expected ELOOP error condition when utime(2) a nested symbolic link:", + errno, strerror(errno)); + } + else if (cktcsid(tc_ptr->tcid, OPEN)) { + + int fd; + TEST( open(tc_ptr->fn_arg[1], O_CREAT) ); + fd=TEST_RETURN; + errno=TEST_ERRNO; + if ((fd == -1) && (errno == ELOOP)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s errno:%d %s", + "Expected ELOOP error condition when open(2) a nested symbolic link:", + errno, strerror(errno)); + } + else + tst_resm(TBROK, "Unknown test case processing actions declared"); +} + +/*********************************************************************** + * This routine checks for the return of ENOTDIR errno from requested + * system call + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_ENOTDIR(tc_ptr) +struct all_test_cases *tc_ptr; +{ + if (cktcsid(tc_ptr->tcid, RMDIR)) { + + TEST( mkdir(tc_ptr->fn_arg[0], MODE) ); + errno=TEST_ERRNO; + if (TEST_RETURN == -1) + tst_resm(TBROK, "mkdir(2) Failure when creating %s", + tc_ptr->fn_arg[0]); + else if ((rmdir(tc_ptr->fn_arg[1]) == -1) && (errno == ENOTDIR)) { + + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + rmdir(tc_ptr->fn_arg[0]); + } + else + tst_resm(TFAIL, "%s %s errno:%d %s", + "Expected ENOTDIR error for removing a non-existent", + "directory through a symbolic link file was not received,", + errno, strerror(errno)); + } + else + tst_resm(TBROK, "Unknown test case processing actions declared"); +} + +/*********************************************************************** + * This routine checks for the return of EXDEV errno from requested + * system call + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_EXDEV(tc_ptr) +struct all_test_cases *tc_ptr; +{ + if (cktcsid(tc_ptr->tcid, RENAME)) { + + TEST( rename(tc_ptr->fn_arg[1], Y_A_S_FILE) ); + errno=TEST_ERRNO; + if ((TEST_RETURN == -1) && (errno == EXDEV)) { + if (see_if_a_symlink(Y_A_S_FILE) == -1) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s %s %s file outside of current file system", + "rename(3) returned -1 when trying to move symbolic link file", + "outside of current file system, but created", Y_A_S_FILE); + } + else { + tst_resm(TFAIL, "%s %s errno:%d %s", + "Expected EXDEV error for renaming an existing symbolic", + "link file to a location outside of existing file system,", + errno, strerror(errno)); + delete_files("/NiCkEr", NULL); + } + } + else + tst_resm(TBROK, "Unknown test case processing actions declared"); +} + +/*********************************************************************** + * This routine checks for the return of ENAMETOOLONG errno from requested + * system call + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_ENAMETOOLONG(tc_ptr) +struct all_test_cases *tc_ptr; +{ + int ret; + + if (cktcsid(tc_ptr->tcid, SYMLINK)) { + + TEST( symlink(tc_ptr->fn_arg[0], full_path) ); + errno=TEST_ERRNO; + if ((TEST_RETURN == -1) && (errno == ENAMETOOLONG)) + if (see_if_a_symlink(full_path) == -1) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s %s %d %s", + "symlink(2) returned -1 when trying to create a symbolic", + "link file whose name exceeded", (PATH_MAX+1), + "characters, but it created the symbolic link file"); + else + tst_resm(TFAIL, + "Expected ENAMETOOLONG error when creating %s symbolic link file with a path exceeding %d characters: errno:%d %s", + tc_ptr->fn_arg[1], (PATH_MAX+1), errno, strerror(errno)); + } + else if (cktcsid(tc_ptr->tcid, READLINK)) { + + char scratch[PATH_MAX+1]; + + ret=readlink(full_path, scratch, strlen(full_path)); + if (( ret == -1) && (errno == ENAMETOOLONG)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, + "Expected ENAMETOOLONG error when reading %s symbolic link file with a path exceeding %d characters: errno:%d %s", + tc_ptr->fn_arg[1], (PATH_MAX+1), errno, strerror(errno)); + } + else + tst_resm(TBROK, "Unknown test case processing actions declared"); +} + +/*********************************************************************** + * This routine checks for the return of EINVAL errno from requested + * system call + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_EINVAL(tc_ptr) +struct all_test_cases *tc_ptr; +{ + if (cktcsid(tc_ptr->tcid, READLINK)) { + TEST( readlink(tc_ptr->fn_arg[0], test_msg, BUFMAX) ); + errno=TEST_ERRNO; + if (TEST_RETURN == -1) { + if (errno == EINVAL) { + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + } else + tst_resm(TFAIL, "readlink(2) ret:-1, errno:%d, : Exp errno:%d", + errno, EINVAL); + } + else { + tst_resm(TFAIL, "readlink(2) did not returned -1 when reading %s", + "a file which is not a symbolic link file"); + } + } + else + tst_resm(TBROK, "Unknown test case processing actions declared"); +} + +/*********************************************************************** + * This routine checks out the readlink(2) system call for a successful + * invocation + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_readlink(tc_ptr) +struct all_test_cases *tc_ptr; +{ + char scratch[PATH_MAX]; + int ret; + + ret=readlink(tc_ptr->fn_arg[1], scratch, strlen(tc_ptr->fn_arg[0])); + + /*** the TEST macro cannot be used here for some reason ****/ + + if (ret == -1) { + tst_resm(TFAIL, + "readlink(2) failure on %s symbolic link file, errno=%d", + tc_ptr->fn_arg[1], errno); + + } + else if (strncmp(tc_ptr->fn_arg[0], scratch, + strlen(tc_ptr->fn_arg[0])) != 0) { + + /* Must null terminate scratch because readlink(2) doesn't */ + + scratch[strlen(tc_ptr->fn_arg[0])] = '\0'; + + tst_resm(TFAIL, + "readlink(2) Error : Expected %s symbolic link file contents but %s actual contents were returned", + tc_ptr->fn_arg[0], scratch); + } + else if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; +} + +/*********************************************************************** + * This routine checks out the stat(2) system call for a successful + * invocation + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_stat(tc_ptr) +struct all_test_cases *tc_ptr; +{ + if (statter.st_dev != asymlink.st_dev) + tst_resm(TFAIL, + "stat of symbolic link reference to object device info %ld != stat of object file device info %ld", + statter.st_dev, asymlink.st_dev); + + else if (statter.st_mode != asymlink.st_mode) + tst_resm(TFAIL, + "stat of symbolic link reference to object file permissions %ld != stat of object file permissions %ld", + statter.st_mode, asymlink.st_mode); + + else if (statter.st_nlink != asymlink.st_nlink) + tst_resm(TFAIL, + "stat of symbolic link reference to object file link count %ld != stat of object file link count %ld", + statter.st_nlink, asymlink.st_nlink); + + else if (statter.st_uid != asymlink.st_uid) + tst_resm(TFAIL, + "stat of symbolic link reference to object file uid %ld != stat of object file uid %ld", + statter.st_uid, asymlink.st_uid); + + else if (statter.st_gid != asymlink.st_gid) + tst_resm(TFAIL, + "stat of symbolic link reference to object file gid %ld != stat of object file gid %ld", + statter.st_gid, asymlink.st_gid); + + else if (statter.st_size != asymlink.st_size) + tst_resm(TFAIL, + "stat of symbolic link reference to object file size %ld != stat of object file size %ld", + statter.st_size, asymlink.st_size); + + else if (statter.st_atime != asymlink.st_atime) + tst_resm(TFAIL, + "stat of symbolic link reference to object access time %ld != stat of object file access time %ld", + statter.st_atime, asymlink.st_atime); + + else if (statter.st_mtime != asymlink.st_mtime) + tst_resm(TFAIL, + "stat of symbolic link reference to object modify time %ld != stat of object file modify time %ld", + statter.st_atime, asymlink.st_atime); + + else if (statter.st_ctime != asymlink.st_ctime) + tst_resm(TFAIL, + "stat of symbolic link reference to object change time %ld != stat of object file change time %ld", + statter.st_atime, asymlink.st_atime); + else if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; +} + +/*********************************************************************** + * This routine checks out the chdir(2) system call for a successful + * invocation + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_chdir(tc_ptr) +struct all_test_cases *tc_ptr; +{ + if (mkdir(tc_ptr->fn_arg[2],MODE) == -1) + tst_resm(TFAIL, "Could not create a setup directory file"); + else { + + sprintf(Buf, "mkdir(%s, %#o) was successful\n", tc_ptr->fn_arg[2],MODE); + strcat(Buffer, Buf); + + if (chdir(tc_ptr->fn_arg[1]) == -1) + tst_resm(TFAIL, "%sCould not change a directory file through a %s", + Buffer, "symbolic link which which pointed at object"); + else { + + char *cwd, *getcwd(); + char expected_location[PATH_MAX]; + /* + * Build expected current directory position + */ + strcpy(expected_location, TESTDIR); + strcat(expected_location, "/"); + strcat(expected_location, tc_ptr->fn_arg[2]); + + if ((cwd = getcwd((char *)NULL, 64)) == NULL) + tst_resm(TFAIL, "getcwd(3) FAILURE"); + else if (strcmp(cwd, expected_location) == 0) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else { + tst_resm(TFAIL, "%s%s %s %s not equal to expected %s", Buffer, + "chdir(2) returned successfully, but getcwd(3) indicated", + "new current working directory location", cwd, expected_location); + } + chdir(TESTDIR); + } + rmdir(tc_ptr->fn_arg[2]); + } +} + +/*********************************************************************** + * This routine checks out the link(2) system call for a successful + * invocation + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_link(tc_ptr) +struct all_test_cases *tc_ptr; +{ + struct stat stbuf; + + if (link(tc_ptr->fn_arg[1], "nick") == -1) { + tst_resm(TFAIL, "%slink(%s, \"nick\") failed, errno: %d\n%s %s", + Buffer, tc_ptr->fn_arg[1], errno, + "link of new file to object file via symbolic link file failed", + "when expected not to"); + } + else { + sprintf(Buf, "link(%s, \"nick\") was successful\n", tc_ptr->fn_arg[1]); + strcat(Buffer, Buf); + + if ( STD_FUNCTIONAL_TEST ) { + /* + * Check that links counts were properly set + */ + if (lstat(tc_ptr->fn_arg[1], &asymlink) == -1) { + tst_resm(TBROK, "lstat(%s) failed. errno: %d", + tc_ptr->fn_arg[1], errno); + + } else if (lstat("nick", &statter) == -1) { + tst_resm(TBROK, "lstat(nick) failed, errno:%d", errno); + } else { + if (statter.st_ino == asymlink.st_ino) { + if ((statter.st_nlink ==2) && (asymlink.st_nlink == 2)) { + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + } else { + lstat(tc_ptr->fn_arg[2], &stbuf); + + tst_resm(TFAIL, + "%slink(%s, %s) failed to adjust link count.\n\ + count for nick is %d, count for %s is %d, count for %s is %d.", + Buffer, tc_ptr->fn_arg[1], "nick", + statter.st_nlink, tc_ptr->fn_arg[1], asymlink.st_nlink, + tc_ptr->fn_arg[2], stbuf.st_nlink); + } + } else { + tst_resm(TFAIL, + "%sA lstat of %s (ino:%d) and of\n\t\t\ +%s (ino:%d), does not show them being the same ino.", Buffer, + tc_ptr->fn_arg[1], asymlink.st_ino, "nick", statter.st_ino); + } + } + } + delete_files("nick", NULL); + } +} + +/*********************************************************************** + * This routine checks out the unlink(2) system call for a successful + * invocation + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_unlink(tc_ptr) +struct all_test_cases *tc_ptr; +{ + if (stat(tc_ptr->fn_arg[2], &asymlink) == -1) + tst_resm(TBROK, + "stat(2) Failure when accessing %s object file", tc_ptr->fn_arg[2]); + else if (unlink(tc_ptr->fn_arg[1]) == -1) + tst_resm(TFAIL, "unlink(2) failed when removing symbolic link file"); + else { + sprintf(Buf, "unlink(%s) was successful\n", tc_ptr->fn_arg[1]); + strcat(Buffer, Buf); + if (stat(tc_ptr->fn_arg[2], &statter) == -1) + tst_resm(TFAIL,"%s %s", + "unlink(2) failed because it not only removed symbolic link", + "file which pointed at object file, but object file as well"); + + else + if ((statter.st_ino == asymlink.st_ino) && + (statter.st_dev == asymlink.st_dev) && + (statter.st_size == asymlink.st_size)) + + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s%s %s %s", Buffer, + "unlink(2) failed because it not only removed symbolic link", + "file which pointed at object file, but it changed object", + "file inode information"); + } + +} + +/*********************************************************************** + * This routine checks out the chmod(2) system call for a successful + * invocation + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_chmod(tc_ptr) +struct all_test_cases *tc_ptr; +{ + if (stat(tc_ptr->fn_arg[2], &asymlink) == -1) + tst_resm(TBROK, + "stat(2) Failure when accessing %s object file", tc_ptr->fn_arg[2]); + else if (chmod(tc_ptr->fn_arg[1], (MODE | MASK)) == -1) + tst_resm(TFAIL, "%s%s %s", Buffer, + "chmod(2) failed when changing file permission", + "through symbolic link file"); + else { + sprintf(Buf, "chmod(%s, %#o) was successful\n", tc_ptr->fn_arg[1], + (MODE | MASK)); + strcat(Buffer, Buf); + + if (stat(tc_ptr->fn_arg[2], &statter) == -1) + tst_resm(TBROK, + "stat(2) Failure when accessing %s object file", tc_ptr->fn_arg[2]); + else + if ((statter.st_mode == (MODE | MASK)) && + (statter.st_mode != asymlink.st_mode)) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s%s %o to %o %s", Buffer, + "chmod(2) failed to change object file permissions from", + asymlink.st_mode, (MODE | MASK), + "through symbolic link file"); + } + +} + +/*********************************************************************** + * This routine checks out the utime(2) system call for a successful + * invocation + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_utime(tc_ptr) +struct all_test_cases *tc_ptr; +{ + struct utimbuf utimes; + + if (stat(tc_ptr->fn_arg[2], &asymlink) == -1) + tst_resm(TBROK, "stat(2) Failure when accessing %s object file", + tc_ptr->fn_arg[2]); + else { + /* Now add a few values to access and modify times */ + + utimes.actime = asymlink.st_atime + a_time_value; + utimes.modtime = asymlink.st_mtime + a_time_value; + + /* Now hand off to utime(2) via symbolic link file*/ + + if (utime(tc_ptr->fn_arg[1], &utimes) == -1) + tst_resm(TFAIL, "%s %s", + "utime(2) failed to process object file access and modify", + "time updates through symbolic link"); + else { + /* Now verify changes were made */ + + if (stat(tc_ptr->fn_arg[2], &statter) == -1) + tst_resm(TBROK, + "stat(2) Failure when accessing %s object file", + tc_ptr->fn_arg[2]); + else { + time_t temp, diff; + + temp = statter.st_atime - asymlink.st_atime; + diff = (statter.st_mtime - asymlink.st_mtime) - temp; + + if (! diff) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, "%s %s %d greater than original times", + "utime(2) failed to change object file access and", + "modify times through symbolic link to a value", + a_time_value); + } + } + } +} + +/*********************************************************************** + * This routine checks out the rename(2) system call for a successful + * invocation + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_rename(tc_ptr) +struct all_test_cases *tc_ptr; +{ + int pts_at_object = 0; + + + if (stat(tc_ptr->fn_arg[2], &statter) != -1) + pts_at_object=1; + + TEST (rename(tc_ptr->fn_arg[1], A_S_FILE) ); + errno=TEST_ERRNO; + if (TEST_RETURN == -1) + tst_resm(TFAIL, "rename(3) failed to rename %s symbolic link file to %s", + tc_ptr->fn_arg[2], A_S_FILE); + else if (pts_at_object) + if (ck_both(tc_ptr->fn_arg[0], A_S_FILE, tc_ptr->fn_arg[2])) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, test_msg); + else if ( ! ck_symlink(tc_ptr->fn_arg[0], A_S_FILE, NULL)) + tst_resm(TFAIL, test_msg); + else if (stat(tc_ptr->fn_arg[1], &asymlink) != -1) + tst_resm(TFAIL, + "rename(3) did not remove %s when renaming to %s", + tc_ptr->fn_arg[1], A_S_FILE); + else if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; +} + +/*********************************************************************** + * This routine checks out the open(2) system call for a successful + * invocation + * + * Argument is pointer to test_objects array of structures of type + * all_test_cases + ***********************************************************************/ +void +do_open(tc_ptr) +struct all_test_cases *tc_ptr; +{ + int fd = -1; + int ret, pts_at_object = 0; + char scratch[PATH_MAX]; + + + if (stat(tc_ptr->fn_arg[2], &statter) != -1) + pts_at_object=1; + + if (pts_at_object) { + TEST( open(tc_ptr->fn_arg[1], O_RDWR) ); + errno=TEST_ERRNO; + if ((fd=TEST_RETURN) == -1) { + tst_resm(TFAIL, + "open(2) Failure when opening object file through symbolic link file"); + return; + } + } + else { + TEST(open(tc_ptr->fn_arg[1], (O_CREAT | O_RDWR), MODE) ); + errno=TEST_ERRNO; + if ((fd=TEST_RETURN) == -1) { + tst_resm(TFAIL, + "open(2) Failure when creating object file through symbolic link file"); + return; + } + } + if ((ret=write(fd, BIG_STRING, strlen(BIG_STRING))) == -1) { + tst_resm(TFAIL, + "write(2) Failure to object file opened through a symbolic link file: errno:%d", + errno); + } + else if (ret != strlen(BIG_STRING)) { + tst_resm(TFAIL, + "write(2) Failed to write %d bytes to object file opened through a symbolic link file", + strlen(BIG_STRING)); + } + else if (lseek(fd, 0L, 0) == -1) { + tst_resm(TFAIL, + "lseek(2) Failed to position to beginning of object file opened through a symbolic link file: errno = %d", + errno); + } + else if ((ret=read(fd, scratch, strlen(BIG_STRING))) == -1) { + tst_resm(TFAIL, + "read(2) Failure of object file opened through a symbolic link file: errno = %d", + errno); + } + else if (ret != strlen(BIG_STRING)) { + tst_resm(TFAIL, + "read(2) Failed to read %d bytes to object file opened through a symbolic link file", + strlen(BIG_STRING)); + } + else if (strncmp(BIG_STRING, scratch, strlen(BIG_STRING)) != 0) { + tst_resm(TFAIL, + "Content of write(2) and read(2) Failed to object file through symbolic link file was not as expected. Expected %s and read returned %s", + BIG_STRING, scratch); + } + else { + /* + * Close off symbolic link file to object file access + */ + if (close(fd) == -1) { + tst_resm(TFAIL, + "close(2) Failure when closing object file accessed symbolic link file"); + } + /* + * Now, lets open up and read object file and compare contents + */ + else if ((fd=open(tc_ptr->fn_arg[0], O_RDONLY)) == -1) { + tst_resm(TFAIL, "open(2) Failure when opening %s file: errno:%d %s", + tc_ptr->fn_arg[0], errno, strerror(errno)); + } + else if ((ret=read(fd, scratch, strlen(BIG_STRING))) == -1) { + tst_resm(TFAIL, + "read(2) Failure of object file opened through a symbolic link file: errno:%d", errno); + } + else if (ret != strlen(BIG_STRING)) { + tst_resm(TFAIL, + "read(2) Failed to read %d bytes to object file opened through a symbolic link file", + strlen(BIG_STRING)); + } + else if (strncmp(BIG_STRING, scratch, strlen(BIG_STRING)) != 0) { + tst_resm(TFAIL, + "Content of write(2) and read(2) Failed to object file through symbolic link file was not as expected. Expected %s and read returned %s", + BIG_STRING, scratch); + } + else if (pts_at_object) { + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + } + else { /* Insure newly created object file is pointed at */ + if (ck_both(tc_ptr->fn_arg[0], tc_ptr->fn_arg[1], tc_ptr->fn_arg[0])) + if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST ) + tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]); + else + Tst_count++; + else + tst_resm(TFAIL, test_msg); + } + close(fd); + } +} + +/*************************************************************** + * 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(); + + /* 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; + + /* remove temporary directory and all files in it. */ + tst_rmdir(); + + /* exit with return code appropriate for results */ + tst_exit(); + +} /* End cleanup() */ + + +/* + * + */ +void help() +{ + int ind; + + printf(" -T id Determines which tests cases to execute:\n"); + + for (ind=0; ind<sizeof(all_tcses)/sizeof(struct tcses ); ind++) { + printf(" %s/%s - %s\n", all_tcses[ind].tcid, all_tcses[ind].syscall, + all_tcses[ind].desc); + } +} diff --git a/winsup/testsuite/winsup.api/ltp/symlink02.c b/winsup/testsuite/winsup.api/ltp/symlink02.c new file mode 100644 index 000000000..d303e822f --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/symlink02.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/sync01.c b/winsup/testsuite/winsup.api/ltp/sync01.c new file mode 100644 index 000000000..acb1782a9 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/sync01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/time01.c b/winsup/testsuite/winsup.api/ltp/time01.c new file mode 100644 index 000000000..60da86295 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/time01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/times01.c b/winsup/testsuite/winsup.api/ltp/times01.c new file mode 100644 index 000000000..e80aaaf0d --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/times01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/ulimit01.c b/winsup/testsuite/winsup.api/ltp/ulimit01.c new file mode 100644 index 000000000..2ca9672be --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/ulimit01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/umask01.c b/winsup/testsuite/winsup.api/ltp/umask01.c new file mode 100644 index 000000000..fcf767b7e --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/umask01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/uname01.c b/winsup/testsuite/winsup.api/ltp/uname01.c new file mode 100644 index 000000000..6e46f9b24 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/uname01.c @@ -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() */ diff --git a/winsup/testsuite/winsup.api/ltp/unlink05.c b/winsup/testsuite/winsup.api/ltp/unlink05.c new file mode 100644 index 000000000..0bb5b7393 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/unlink05.c @@ -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)); + } +} diff --git a/winsup/testsuite/winsup.api/ltp/unlink06.c b/winsup/testsuite/winsup.api/ltp/unlink06.c new file mode 100644 index 000000000..5fc323303 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/unlink06.c @@ -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)); + } +} diff --git a/winsup/testsuite/winsup.api/ltp/unlink07.c b/winsup/testsuite/winsup.api/ltp/unlink07.c new file mode 100644 index 000000000..cf48a4660 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/unlink07.c @@ -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; +} + diff --git a/winsup/testsuite/winsup.api/ltp/wait02.c b/winsup/testsuite/winsup.api/ltp/wait02.c new file mode 100644 index 000000000..6c91f4f05 --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/wait02.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/ltp/write01.c b/winsup/testsuite/winsup.api/ltp/write01.c new file mode 100644 index 000000000..e137ee9cd --- /dev/null +++ b/winsup/testsuite/winsup.api/ltp/write01.c @@ -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() */ + + diff --git a/winsup/testsuite/winsup.api/sigchld.c b/winsup/testsuite/winsup.api/sigchld.c new file mode 100644 index 000000000..a7d1069b7 --- /dev/null +++ b/winsup/testsuite/winsup.api/sigchld.c @@ -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 ); +} diff --git a/winsup/testsuite/winsup.api/waitpid.c b/winsup/testsuite/winsup.api/waitpid.c new file mode 100644 index 000000000..9845cd1a4 --- /dev/null +++ b/winsup/testsuite/winsup.api/waitpid.c @@ -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); + } +} diff --git a/winsup/testsuite/winsup.api/winsup.exp b/winsup/testsuite/winsup.api/winsup.exp index 96e7c7cf4..743f4cfaa 100644 --- a/winsup/testsuite/winsup.api/winsup.exp +++ b/winsup/testsuite/winsup.api/winsup.exp @@ -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" + } } } } |