From a4637e83f3bb0e88f86bf70dd3af439b37eaa385 Mon Sep 17 00:00:00 2001 From: cvs2svn <> Date: Mon, 22 Dec 2003 00:59:56 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'csl-arm-2003-q4'. Sprout from master 2003-12-22 00:59:55 UTC DJ Delorie '* configure.in (*-*-uclinux): Exclude newlib, libgloss and rda.' Cherrypick from cygnus 1999-05-03 07:29:06 UTC Richard Henderson '19990502 sourceware import': COPYING COPYING.LIB README config/mh-armpic config/mh-elfalphapic config/mh-m68kpic config/mh-papic config/mh-ppcpic config/mh-x86pic config/mt-d30v config/mt-netware config/mt-ospace etc/add-log.el etc/add-log.vi etc/configbuild.ein etc/configbuild.fig etc/configbuild.jin etc/configbuild.tin etc/configdev.ein etc/configdev.fig etc/configdev.jin etc/configdev.tin etc/configure etc/configure.in include/aout/hp.h include/aout/hppa.h include/coff/sym.h include/coff/symconst.h include/fopen-bin.h include/fopen-same.h include/fopen-vms.h include/gdbm.h include/mpw/ChangeLog include/mpw/README include/mpw/dir.h include/mpw/dirent.h include/mpw/fcntl.h include/mpw/grp.h include/mpw/mpw.h include/mpw/pwd.h include/mpw/stat.h include/mpw/sys/file.h include/mpw/sys/param.h include/mpw/sys/resource.h include/mpw/sys/stat.h include/mpw/sys/time.h include/mpw/sys/types.h include/mpw/utime.h include/mpw/varargs.h include/nlm/ppc-ext.h include/opcode/mn10200.h include/opcode/tahoe.h include/opcode/tic30.h makefile.vms move-if-change mpw-README mpw-build.in mpw-config.in mpw-configure mpw-install setup.com ylwrap Delete: djunpack.bat winsup/CYGWIN_LICENSE winsup/ChangeLog winsup/Makefile.common winsup/Makefile.in winsup/bz2lib/CHANGES winsup/bz2lib/ChangeLog winsup/bz2lib/LICENSE winsup/bz2lib/Makefile winsup/bz2lib/Makefile-libbz2_so winsup/bz2lib/Makefile.in winsup/bz2lib/README winsup/bz2lib/README.COMPILATION.PROBLEMS winsup/bz2lib/Y2K_INFO winsup/bz2lib/aclocal.m4 winsup/bz2lib/blocksort.c winsup/bz2lib/bzip2.1 winsup/bz2lib/bzip2.1.preformatted winsup/bz2lib/bzip2.c winsup/bz2lib/bzip2.txt winsup/bz2lib/bzip2recover.c winsup/bz2lib/bzlib.c winsup/bz2lib/bzlib.h winsup/bz2lib/bzlib_private.h winsup/bz2lib/compress.c winsup/bz2lib/configure winsup/bz2lib/configure.in winsup/bz2lib/crctable.c winsup/bz2lib/decompress.c winsup/bz2lib/dlltest.c winsup/bz2lib/dlltest.dsp winsup/bz2lib/huffman.c winsup/bz2lib/libbz2.def winsup/bz2lib/libbz2.dsp winsup/bz2lib/makefile.msc winsup/bz2lib/manual.ps winsup/bz2lib/manual.texi winsup/bz2lib/manual_1.html winsup/bz2lib/manual_2.html winsup/bz2lib/manual_3.html winsup/bz2lib/manual_4.html winsup/bz2lib/manual_toc.html winsup/bz2lib/randtable.c winsup/bz2lib/sample1.bz2 winsup/bz2lib/sample1.ref winsup/bz2lib/sample2.bz2 winsup/bz2lib/sample2.ref winsup/bz2lib/sample3.bz2 winsup/bz2lib/sample3.ref winsup/bz2lib/spewG.c winsup/bz2lib/unzcrash.c winsup/bz2lib/words0 winsup/bz2lib/words1 winsup/bz2lib/words2 winsup/bz2lib/words3 winsup/configure winsup/configure.in winsup/cygserver/ChangeLog winsup/cygserver/Makefile.in winsup/cygserver/README winsup/cygserver/bsd_helper.cc winsup/cygserver/bsd_helper.h winsup/cygserver/bsd_log.cc winsup/cygserver/bsd_log.h winsup/cygserver/bsd_mutex.cc winsup/cygserver/bsd_mutex.h winsup/cygserver/client.cc winsup/cygserver/configure winsup/cygserver/configure.in winsup/cygserver/cygserver-config winsup/cygserver/cygserver.cc winsup/cygserver/cygserver.conf winsup/cygserver/msg.cc winsup/cygserver/process.cc winsup/cygserver/process.h winsup/cygserver/sem.cc winsup/cygserver/shm.cc winsup/cygserver/sysv_msg.cc winsup/cygserver/sysv_sem.cc winsup/cygserver/sysv_shm.cc winsup/cygserver/threaded_queue.cc winsup/cygserver/threaded_queue.h winsup/cygserver/transport.cc winsup/cygserver/transport.h winsup/cygserver/transport_pipes.cc winsup/cygserver/transport_pipes.h winsup/cygserver/transport_sockets.cc winsup/cygserver/transport_sockets.h winsup/cygserver/woutsup.h winsup/cygwin/CYGWIN_LICENSE winsup/cygwin/ChangeLog winsup/cygwin/ChangeLog-1995 winsup/cygwin/ChangeLog-1996 winsup/cygwin/ChangeLog-1997 winsup/cygwin/ChangeLog-1998 winsup/cygwin/ChangeLog-1999 winsup/cygwin/ChangeLog-2000 winsup/cygwin/ChangeLog-2001 winsup/cygwin/ChangeLog-2002 winsup/cygwin/Makefile.in winsup/cygwin/ROADMAP winsup/cygwin/acconfig.h winsup/cygwin/ansi.sgml winsup/cygwin/assert.cc winsup/cygwin/autoload.cc winsup/cygwin/automode.c winsup/cygwin/binmode.c winsup/cygwin/child_info.h winsup/cygwin/config.h.in winsup/cygwin/config/i386/profile.h winsup/cygwin/config/i386/setjmp.c winsup/cygwin/configure winsup/cygwin/configure.in winsup/cygwin/cpuid.h winsup/cygwin/crt0.c winsup/cygwin/cxx.cc winsup/cygwin/cygerrno.h winsup/cygwin/cygheap.cc winsup/cygwin/cygheap.h winsup/cygwin/cygmagic winsup/cygwin/cygmalloc.h winsup/cygwin/cygserver.h winsup/cygwin/cygserver_ipc.h winsup/cygwin/cygserver_msg.h winsup/cygwin/cygserver_sem.h winsup/cygwin/cygserver_shm.h winsup/cygwin/cygthread.cc winsup/cygwin/cygthread.h winsup/cygwin/cygtls.h winsup/cygwin/cygwin-shilka winsup/cygwin/cygwin.din winsup/cygwin/cygwin.sc winsup/cygwin/cygwin_version.h winsup/cygwin/dcrt0.cc winsup/cygwin/debug.cc winsup/cygwin/debug.h winsup/cygwin/delqueue.cc winsup/cygwin/devices.cc winsup/cygwin/devices.h winsup/cygwin/devices.in winsup/cygwin/dir.cc winsup/cygwin/dlfcn.cc winsup/cygwin/dll_init.cc winsup/cygwin/dll_init.h winsup/cygwin/dll_init.sgml winsup/cygwin/dlmalloc.c winsup/cygwin/dlmalloc.h winsup/cygwin/dtable.cc winsup/cygwin/dtable.h winsup/cygwin/dtable.sgml winsup/cygwin/environ.cc winsup/cygwin/environ.h winsup/cygwin/errno.cc winsup/cygwin/exceptions.cc winsup/cygwin/exec.cc winsup/cygwin/external.cc winsup/cygwin/external.sgml winsup/cygwin/fcntl.cc winsup/cygwin/fhandler.cc winsup/cygwin/fhandler.h winsup/cygwin/fhandler_clipboard.cc winsup/cygwin/fhandler_console.cc winsup/cygwin/fhandler_disk_file.cc winsup/cygwin/fhandler_dsp.cc winsup/cygwin/fhandler_fifo.cc winsup/cygwin/fhandler_floppy.cc winsup/cygwin/fhandler_mem.cc winsup/cygwin/fhandler_nodevice.cc winsup/cygwin/fhandler_proc.cc winsup/cygwin/fhandler_process.cc winsup/cygwin/fhandler_random.cc winsup/cygwin/fhandler_raw.cc winsup/cygwin/fhandler_registry.cc winsup/cygwin/fhandler_serial.cc winsup/cygwin/fhandler_socket.cc winsup/cygwin/fhandler_tape.cc winsup/cygwin/fhandler_termios.cc winsup/cygwin/fhandler_tty.cc winsup/cygwin/fhandler_virtual.cc winsup/cygwin/fhandler_windows.cc winsup/cygwin/fhandler_zero.cc winsup/cygwin/flock.cc winsup/cygwin/fork.cc winsup/cygwin/gcrt0.c winsup/cygwin/gendef winsup/cygwin/gendevices winsup/cygwin/gentls_offsets winsup/cygwin/glob.c winsup/cygwin/gmon.c winsup/cygwin/gmon.h winsup/cygwin/grp.cc winsup/cygwin/heap.cc winsup/cygwin/heap.h winsup/cygwin/hires.h winsup/cygwin/how-autoload-works.txt winsup/cygwin/how-cygheap-works.txt winsup/cygwin/how-fhandlers-work.txt winsup/cygwin/how-signals-work.txt winsup/cygwin/how-spawn-works.txt winsup/cygwin/how-to-debug-cygwin.txt winsup/cygwin/how-vfork-works.txt winsup/cygwin/include/a.out.h winsup/cygwin/include/arpa/ftp.h winsup/cygwin/include/arpa/inet.h winsup/cygwin/include/arpa/telnet.h winsup/cygwin/include/asm/byteorder.h winsup/cygwin/include/asm/socket.h winsup/cygwin/include/asm/types.h winsup/cygwin/include/cygwin/acl.h winsup/cygwin/include/cygwin/config.h winsup/cygwin/include/cygwin/core_dump.h winsup/cygwin/include/cygwin/cygwin_dll.h winsup/cygwin/include/cygwin/fs.h winsup/cygwin/include/cygwin/grp.h winsup/cygwin/include/cygwin/hdreg.h winsup/cygwin/include/cygwin/icmp.h winsup/cygwin/include/cygwin/if.h winsup/cygwin/include/cygwin/in.h winsup/cygwin/include/cygwin/in_systm.h winsup/cygwin/include/cygwin/ipc.h winsup/cygwin/include/cygwin/msg.h winsup/cygwin/include/cygwin/mtio.h winsup/cygwin/include/cygwin/rdevio.h winsup/cygwin/include/cygwin/sem.h winsup/cygwin/include/cygwin/shm.h winsup/cygwin/include/cygwin/signal.h winsup/cygwin/include/cygwin/socket.h winsup/cygwin/include/cygwin/sockios.h winsup/cygwin/include/cygwin/stat.h winsup/cygwin/include/cygwin/sysproto.h winsup/cygwin/include/cygwin/types.h winsup/cygwin/include/cygwin/uio.h winsup/cygwin/include/cygwin/version.h winsup/cygwin/include/dlfcn.h winsup/cygwin/include/err.h winsup/cygwin/include/exceptions.h winsup/cygwin/include/fcntl.h winsup/cygwin/include/features.h winsup/cygwin/include/fnmatch.h winsup/cygwin/include/getopt.h winsup/cygwin/include/glob.h winsup/cygwin/include/icmp.h winsup/cygwin/include/inttypes.h winsup/cygwin/include/io.h winsup/cygwin/include/lastlog.h winsup/cygwin/include/limits.h winsup/cygwin/include/mapi.h winsup/cygwin/include/memory.h winsup/cygwin/include/mntent.h winsup/cygwin/include/net/if.h winsup/cygwin/include/netdb.h winsup/cygwin/include/netinet/in.h winsup/cygwin/include/netinet/in_systm.h winsup/cygwin/include/netinet/ip.h winsup/cygwin/include/netinet/ip_icmp.h winsup/cygwin/include/netinet/tcp.h winsup/cygwin/include/netinet/udp.h winsup/cygwin/include/paths.h winsup/cygwin/include/poll.h winsup/cygwin/include/pthread.h winsup/cygwin/include/pty.h winsup/cygwin/include/sched.h winsup/cygwin/include/semaphore.h winsup/cygwin/include/stdint.h winsup/cygwin/include/strings.h winsup/cygwin/include/sys/acl.h winsup/cygwin/include/sys/cdefs.h winsup/cygwin/include/sys/copying.dj winsup/cygwin/include/sys/cygwin.h winsup/cygwin/include/sys/dirent.h winsup/cygwin/include/sys/file.h winsup/cygwin/include/sys/ioctl.h winsup/cygwin/include/sys/ipc.h winsup/cygwin/include/sys/mman.h winsup/cygwin/include/sys/mount.h winsup/cygwin/include/sys/msg.h winsup/cygwin/include/sys/mtio.h winsup/cygwin/include/sys/param.h winsup/cygwin/include/sys/poll.h winsup/cygwin/include/sys/procfs.h winsup/cygwin/include/sys/queue.h winsup/cygwin/include/sys/resource.h winsup/cygwin/include/sys/select.h winsup/cygwin/include/sys/sem.h winsup/cygwin/include/sys/shm.h winsup/cygwin/include/sys/smallprint.h winsup/cygwin/include/sys/socket.h winsup/cygwin/include/sys/soundcard.h winsup/cygwin/include/sys/statfs.h winsup/cygwin/include/sys/strace.h winsup/cygwin/include/sys/syslog.h winsup/cygwin/include/sys/sysmacros.h winsup/cygwin/include/sys/sysproto.h winsup/cygwin/include/sys/termio.h winsup/cygwin/include/sys/termios.h winsup/cygwin/include/sys/ttychars.h winsup/cygwin/include/sys/uio.h winsup/cygwin/include/sys/un.h winsup/cygwin/include/sys/utime.h winsup/cygwin/include/sys/utmp.h winsup/cygwin/include/sys/utsname.h winsup/cygwin/include/sys/vfs.h winsup/cygwin/include/sys/wait.h winsup/cygwin/include/sysexits.h winsup/cygwin/include/syslog.h winsup/cygwin/include/termio.h winsup/cygwin/include/tzfile.h winsup/cygwin/init.cc winsup/cygwin/ioctl.cc winsup/cygwin/ipc.cc winsup/cygwin/lib/_cygwin_crt0_common.cc winsup/cygwin/lib/crt0.h winsup/cygwin/lib/cygwin_attach_dll.c winsup/cygwin/lib/cygwin_crt0.c winsup/cygwin/lib/dll_entry.c winsup/cygwin/lib/dll_main.cc winsup/cygwin/lib/libcmain.c winsup/cygwin/lib/premain0.c winsup/cygwin/lib/premain1.c winsup/cygwin/lib/premain2.c winsup/cygwin/lib/premain3.c winsup/cygwin/lib/pseudo-reloc.c winsup/cygwin/libc/bsdlib.cc winsup/cygwin/libc/fnmatch.c winsup/cygwin/libc/getopt.c winsup/cygwin/libc/iruserok.c winsup/cygwin/localtime.cc winsup/cygwin/malloc.cc winsup/cygwin/malloc_wrapper.cc winsup/cygwin/mcount.c winsup/cygwin/misc-std.sgml winsup/cygwin/miscfuncs.cc winsup/cygwin/mkvers.sh winsup/cygwin/mmap.cc winsup/cygwin/msg.cc winsup/cygwin/net.cc winsup/cygwin/netdb.cc winsup/cygwin/newsym winsup/cygwin/ntdll.h winsup/cygwin/ntea.cc winsup/cygwin/passwd.cc winsup/cygwin/path.cc winsup/cygwin/path.h winsup/cygwin/path.sgml winsup/cygwin/perprocess.h winsup/cygwin/perthread.h winsup/cygwin/pinfo.cc winsup/cygwin/pinfo.h winsup/cygwin/pipe.cc winsup/cygwin/poll.cc winsup/cygwin/posix.sgml winsup/cygwin/profil.c winsup/cygwin/profil.h winsup/cygwin/pseudo-reloc.cc winsup/cygwin/pthread.cc winsup/cygwin/pwdgrp.h winsup/cygwin/regex/COPYRIGHT winsup/cygwin/regex/cclass.h winsup/cygwin/regex/cname.h winsup/cygwin/regex/engine.c winsup/cygwin/regex/engine.ih winsup/cygwin/regex/mkh winsup/cygwin/regex/regcomp.c winsup/cygwin/regex/regcomp.ih winsup/cygwin/regex/regerror.c winsup/cygwin/regex/regerror.ih winsup/cygwin/regex/regex.3 winsup/cygwin/regex/regex.7 winsup/cygwin/regex/regex.h winsup/cygwin/regex/regex2.h winsup/cygwin/regex/regexec.c winsup/cygwin/regex/regfree.c winsup/cygwin/regex/tests winsup/cygwin/regex/utils.h winsup/cygwin/regexp/COPYRIGHT winsup/cygwin/regexp/README winsup/cygwin/regexp/regexp.h winsup/cygwin/regexp/regmagic.h winsup/cygwin/regexp/v8_regerror.c winsup/cygwin/regexp/v8_regexp.c winsup/cygwin/regexp/v8_regsub.c winsup/cygwin/registry.cc winsup/cygwin/registry.h winsup/cygwin/resource.cc winsup/cygwin/rmsym winsup/cygwin/scandir.cc winsup/cygwin/sched.cc winsup/cygwin/sec_acl.cc winsup/cygwin/sec_helper.cc winsup/cygwin/security.cc winsup/cygwin/security.h winsup/cygwin/select.cc winsup/cygwin/select.h winsup/cygwin/sem.cc winsup/cygwin/shared.cc winsup/cygwin/shared.sgml winsup/cygwin/shared_info.h winsup/cygwin/shm.cc winsup/cygwin/signal.cc winsup/cygwin/sigproc.cc winsup/cygwin/sigproc.h winsup/cygwin/smallprint.c winsup/cygwin/spawn.cc winsup/cygwin/speclib winsup/cygwin/stackdump.sgml winsup/cygwin/strace.cc winsup/cygwin/string.h winsup/cygwin/strsep.cc winsup/cygwin/sync.cc winsup/cygwin/sync.h winsup/cygwin/syscalls.cc winsup/cygwin/sysconf.cc winsup/cygwin/syslog.cc winsup/cygwin/termios.cc winsup/cygwin/textmode.c winsup/cygwin/thread.cc winsup/cygwin/thread.h winsup/cygwin/times.cc winsup/cygwin/tlsoffsets.h winsup/cygwin/tty.cc winsup/cygwin/tty.h winsup/cygwin/tz_posixrules.h winsup/cygwin/uinfo.cc winsup/cygwin/uname.cc winsup/cygwin/wait.cc winsup/cygwin/winbase.h winsup/cygwin/wincap.cc winsup/cygwin/wincap.h winsup/cygwin/window.cc winsup/cygwin/winsup.h winsup/cygwin/winver.rc winsup/cygwin/wsock_event.h winsup/doc/ChangeLog winsup/doc/Makefile.in winsup/doc/calls.texinfo winsup/doc/changes.texinfo winsup/doc/configure winsup/doc/configure.in winsup/doc/copy.texinfo winsup/doc/cygwin-api.in.sgml winsup/doc/cygwin-ug-net.in.sgml winsup/doc/cygwin-ug.in.sgml winsup/doc/cygwinenv.sgml winsup/doc/dll.sgml winsup/doc/doctool.c winsup/doc/doctool.txt winsup/doc/effectively.sgml winsup/doc/faq.texinfo winsup/doc/fhandler-tut.txt winsup/doc/filemodes.sgml winsup/doc/gcc.sgml winsup/doc/gdb.sgml winsup/doc/history.texinfo winsup/doc/how-api.texinfo winsup/doc/how-programming.texinfo winsup/doc/how-resources.texinfo winsup/doc/how-using.texinfo winsup/doc/how.texinfo winsup/doc/install.texinfo winsup/doc/legal.sgml winsup/doc/ntsec.sgml winsup/doc/overview.sgml winsup/doc/overview2.sgml winsup/doc/pathnames.sgml winsup/doc/programming.sgml winsup/doc/readme.texinfo winsup/doc/relnotes.texinfo winsup/doc/setup-net.sgml winsup/doc/setup.sgml winsup/doc/setup2.sgml winsup/doc/textbinary.sgml winsup/doc/using.sgml winsup/doc/what.texinfo winsup/doc/who.texinfo winsup/doc/windres.sgml winsup/mingw/CRT_fp10.c winsup/mingw/CRT_fp8.c winsup/mingw/CRT_noglob.c winsup/mingw/CRTfmode.c winsup/mingw/CRTglob.c winsup/mingw/CRTinit.c winsup/mingw/ChangeLog winsup/mingw/Makefile.in winsup/mingw/README winsup/mingw/TODO winsup/mingw/binmode.c winsup/mingw/config.guess winsup/mingw/config.sub winsup/mingw/configure winsup/mingw/configure.in winsup/mingw/crt1.c winsup/mingw/crtdll.def winsup/mingw/crtmt.c winsup/mingw/crtst.c winsup/mingw/dllcrt1.c winsup/mingw/dllmain.c winsup/mingw/gccmain.c winsup/mingw/include/_mingw.h winsup/mingw/include/assert.h winsup/mingw/include/complex.h winsup/mingw/include/conio.h winsup/mingw/include/ctype.h winsup/mingw/include/dir.h winsup/mingw/include/direct.h winsup/mingw/include/dirent.h winsup/mingw/include/dos.h winsup/mingw/include/errno.h winsup/mingw/include/excpt.h winsup/mingw/include/fcntl.h winsup/mingw/include/fenv.h winsup/mingw/include/float.h winsup/mingw/include/getopt.h winsup/mingw/include/inttypes.h winsup/mingw/include/io.h winsup/mingw/include/limits.h winsup/mingw/include/locale.h winsup/mingw/include/malloc.h winsup/mingw/include/math.h winsup/mingw/include/mbctype.h winsup/mingw/include/mbstring.h winsup/mingw/include/mem.h winsup/mingw/include/memory.h winsup/mingw/include/process.h winsup/mingw/include/search.h winsup/mingw/include/setjmp.h winsup/mingw/include/share.h winsup/mingw/include/signal.h winsup/mingw/include/stdarg.h winsup/mingw/include/stddef.h winsup/mingw/include/stdint.h winsup/mingw/include/stdio.h winsup/mingw/include/stdlib.h winsup/mingw/include/string.h winsup/mingw/include/strings.h winsup/mingw/include/sys/fcntl.h winsup/mingw/include/sys/file.h winsup/mingw/include/sys/locking.h winsup/mingw/include/sys/param.h winsup/mingw/include/sys/stat.h winsup/mingw/include/sys/time.h winsup/mingw/include/sys/timeb.h winsup/mingw/include/sys/types.h winsup/mingw/include/sys/unistd.h winsup/mingw/include/sys/utime.h winsup/mingw/include/tchar.h winsup/mingw/include/time.h winsup/mingw/include/unistd.h winsup/mingw/include/utime.h winsup/mingw/include/values.h winsup/mingw/include/varargs.h winsup/mingw/include/wchar.h winsup/mingw/include/wctype.h winsup/mingw/init.c winsup/mingw/install-sh winsup/mingw/isascii.c winsup/mingw/iscsym.c winsup/mingw/iscsymf.c winsup/mingw/jamfile winsup/mingw/main.c winsup/mingw/mingwex/Makefile.in winsup/mingw/mingwex/_Exit.c winsup/mingw/mingwex/atoll.c winsup/mingw/mingwex/complex/cabs.c winsup/mingw/mingwex/complex/cacos.c winsup/mingw/mingwex/complex/cacosh.c winsup/mingw/mingwex/complex/casin.c winsup/mingw/mingwex/complex/casinh.c winsup/mingw/mingwex/complex/catan.c winsup/mingw/mingwex/complex/catanh.c winsup/mingw/mingwex/complex/ccos.c winsup/mingw/mingwex/complex/ccosh.c winsup/mingw/mingwex/complex/cexp.c winsup/mingw/mingwex/complex/cimag.c winsup/mingw/mingwex/complex/clog.c winsup/mingw/mingwex/complex/cpow.c winsup/mingw/mingwex/complex/cproj.c winsup/mingw/mingwex/complex/creal.c winsup/mingw/mingwex/complex/csin.c winsup/mingw/mingwex/complex/csinh.c winsup/mingw/mingwex/complex/csqrt.c winsup/mingw/mingwex/complex/ctan.c winsup/mingw/mingwex/complex/ctanh.c winsup/mingw/mingwex/configure winsup/mingw/mingwex/configure.in winsup/mingw/mingwex/dirent.c winsup/mingw/mingwex/feclearexcept.c winsup/mingw/mingwex/fegetenv.c winsup/mingw/mingwex/fegetexceptflag.c winsup/mingw/mingwex/fegetround.c winsup/mingw/mingwex/feholdexcept.c winsup/mingw/mingwex/feraiseexcept.c winsup/mingw/mingwex/fesetenv.c winsup/mingw/mingwex/fesetexceptflag.c winsup/mingw/mingwex/fesetround.c winsup/mingw/mingwex/fetestexcept.c winsup/mingw/mingwex/feupdateenv.c winsup/mingw/mingwex/fwide.c winsup/mingw/mingwex/getopt.c winsup/mingw/mingwex/imaxabs.c winsup/mingw/mingwex/imaxdiv.c winsup/mingw/mingwex/ldtoa.c winsup/mingw/mingwex/lltoa.c winsup/mingw/mingwex/lltow.c winsup/mingw/mingwex/math/acosf.c winsup/mingw/mingwex/math/acosl.c winsup/mingw/mingwex/math/asinf.c winsup/mingw/mingwex/math/asinl.c winsup/mingw/mingwex/math/atan2f.c winsup/mingw/mingwex/math/atan2l.c winsup/mingw/mingwex/math/atanf.c winsup/mingw/mingwex/math/atanl.c winsup/mingw/mingwex/math/cbrt.c winsup/mingw/mingwex/math/cbrtf.c winsup/mingw/mingwex/math/cbrtl.c winsup/mingw/mingwex/math/ceilf.S winsup/mingw/mingwex/math/ceill.S winsup/mingw/mingwex/math/cephes_emath.c winsup/mingw/mingwex/math/cephes_emath.h winsup/mingw/mingwex/math/cephes_mconf.h winsup/mingw/mingwex/math/copysign.S winsup/mingw/mingwex/math/copysignf.S winsup/mingw/mingwex/math/copysignl.S winsup/mingw/mingwex/math/cosf.S winsup/mingw/mingwex/math/coshf.c winsup/mingw/mingwex/math/coshl.c winsup/mingw/mingwex/math/cosl.S winsup/mingw/mingwex/math/exp2.S winsup/mingw/mingwex/math/exp2f.S winsup/mingw/mingwex/math/exp2l.S winsup/mingw/mingwex/math/expf.c winsup/mingw/mingwex/math/expl.c winsup/mingw/mingwex/math/fabs.c winsup/mingw/mingwex/math/fabsf.c winsup/mingw/mingwex/math/fabsl.c winsup/mingw/mingwex/math/fdim.c winsup/mingw/mingwex/math/fdimf.c winsup/mingw/mingwex/math/fdiml.c winsup/mingw/mingwex/math/floorf.S winsup/mingw/mingwex/math/floorl.S winsup/mingw/mingwex/math/fma.S winsup/mingw/mingwex/math/fmaf.S winsup/mingw/mingwex/math/fmal.c winsup/mingw/mingwex/math/fmax.c winsup/mingw/mingwex/math/fmaxf.c winsup/mingw/mingwex/math/fmaxl.c winsup/mingw/mingwex/math/fmin.c winsup/mingw/mingwex/math/fminf.c winsup/mingw/mingwex/math/fminl.c winsup/mingw/mingwex/math/fmodf.c winsup/mingw/mingwex/math/fmodl.c winsup/mingw/mingwex/math/fp_consts.c winsup/mingw/mingwex/math/fp_consts.h winsup/mingw/mingwex/math/fp_constsf.c winsup/mingw/mingwex/math/fp_constsl.c winsup/mingw/mingwex/math/fpclassify.c winsup/mingw/mingwex/math/fpclassifyf.c winsup/mingw/mingwex/math/fpclassifyl.c winsup/mingw/mingwex/math/frexpf.c winsup/mingw/mingwex/math/frexpl.S winsup/mingw/mingwex/math/fucom.c winsup/mingw/mingwex/math/hypotf.c winsup/mingw/mingwex/math/hypotl.c winsup/mingw/mingwex/math/ilogb.S winsup/mingw/mingwex/math/ilogbf.S winsup/mingw/mingwex/math/ilogbl.S winsup/mingw/mingwex/math/isnan.c winsup/mingw/mingwex/math/isnanf.c winsup/mingw/mingwex/math/isnanl.c winsup/mingw/mingwex/math/ldexpf.c winsup/mingw/mingwex/math/ldexpl.c winsup/mingw/mingwex/math/lgamma.c winsup/mingw/mingwex/math/lgammaf.c winsup/mingw/mingwex/math/lgammal.c winsup/mingw/mingwex/math/llrint.c winsup/mingw/mingwex/math/llrintf.c winsup/mingw/mingwex/math/llrintl.c winsup/mingw/mingwex/math/llround.c winsup/mingw/mingwex/math/llroundf.c winsup/mingw/mingwex/math/llroundl.c winsup/mingw/mingwex/math/log10f.S winsup/mingw/mingwex/math/log10l.S winsup/mingw/mingwex/math/log1p.S winsup/mingw/mingwex/math/log1pf.S winsup/mingw/mingwex/math/log1pl.S winsup/mingw/mingwex/math/log2.S winsup/mingw/mingwex/math/log2f.S winsup/mingw/mingwex/math/log2l.S winsup/mingw/mingwex/math/logb.c winsup/mingw/mingwex/math/logbf.c winsup/mingw/mingwex/math/logbl.c winsup/mingw/mingwex/math/logf.S winsup/mingw/mingwex/math/logl.S winsup/mingw/mingwex/math/lrint.c winsup/mingw/mingwex/math/lrintf.c winsup/mingw/mingwex/math/lrintl.c winsup/mingw/mingwex/math/lround.c winsup/mingw/mingwex/math/lroundf.c winsup/mingw/mingwex/math/lroundl.c winsup/mingw/mingwex/math/modff.c winsup/mingw/mingwex/math/modfl.c winsup/mingw/mingwex/math/nearbyint.S winsup/mingw/mingwex/math/nearbyintf.S winsup/mingw/mingwex/math/nearbyintl.S winsup/mingw/mingwex/math/nextafterf.c winsup/mingw/mingwex/math/pow.c winsup/mingw/mingwex/math/powf.c winsup/mingw/mingwex/math/powi.c winsup/mingw/mingwex/math/powif.c winsup/mingw/mingwex/math/powil.c winsup/mingw/mingwex/math/powl.c winsup/mingw/mingwex/math/remainder.S winsup/mingw/mingwex/math/remainderf.S winsup/mingw/mingwex/math/remainderl.S winsup/mingw/mingwex/math/remquo.S winsup/mingw/mingwex/math/remquof.S winsup/mingw/mingwex/math/remquol.S winsup/mingw/mingwex/math/rint.c winsup/mingw/mingwex/math/rintf.c winsup/mingw/mingwex/math/rintl.c winsup/mingw/mingwex/math/round.c winsup/mingw/mingwex/math/roundf.c winsup/mingw/mingwex/math/roundl.c winsup/mingw/mingwex/math/s_erf.c winsup/mingw/mingwex/math/scalbn.S winsup/mingw/mingwex/math/scalbnf.S winsup/mingw/mingwex/math/scalbnl.S winsup/mingw/mingwex/math/sf_erf.c winsup/mingw/mingwex/math/signbit.c winsup/mingw/mingwex/math/signbitf.c winsup/mingw/mingwex/math/signbitl.c winsup/mingw/mingwex/math/sinf.S winsup/mingw/mingwex/math/sinhf.c winsup/mingw/mingwex/math/sinhl.c winsup/mingw/mingwex/math/sinl.S winsup/mingw/mingwex/math/sqrtf.c winsup/mingw/mingwex/math/sqrtl.c winsup/mingw/mingwex/math/tanf.S winsup/mingw/mingwex/math/tanhf.c winsup/mingw/mingwex/math/tanhl.c winsup/mingw/mingwex/math/tanl.S winsup/mingw/mingwex/math/tgamma.c winsup/mingw/mingwex/math/tgammaf.c winsup/mingw/mingwex/math/tgammal.c winsup/mingw/mingwex/math/trunc.c winsup/mingw/mingwex/math/truncf.c winsup/mingw/mingwex/math/truncl.c winsup/mingw/mingwex/mbsinit.c winsup/mingw/mingwex/mingw-fseek.c winsup/mingw/mingwex/sitest.c winsup/mingw/mingwex/stdio/snprintf.c winsup/mingw/mingwex/stdio/snwprintf.c winsup/mingw/mingwex/stdio/vfscanf.c winsup/mingw/mingwex/stdio/vfwscanf.c winsup/mingw/mingwex/stdio/vscanf.c winsup/mingw/mingwex/stdio/vsnprintf.c winsup/mingw/mingwex/stdio/vsnwprintf.c winsup/mingw/mingwex/stdio/vsscanf.c winsup/mingw/mingwex/stdio/vswscanf.c winsup/mingw/mingwex/stdio/vwscanf.c winsup/mingw/mingwex/strtof.c winsup/mingw/mingwex/strtoimax.c winsup/mingw/mingwex/strtold.c winsup/mingw/mingwex/strtoumax.c winsup/mingw/mingwex/testwmem.c winsup/mingw/mingwex/ulltoa.c winsup/mingw/mingwex/ulltow.c winsup/mingw/mingwex/wcstof.c winsup/mingw/mingwex/wcstoimax.c winsup/mingw/mingwex/wcstold.c winsup/mingw/mingwex/wcstoumax.c winsup/mingw/mingwex/wdirent.c winsup/mingw/mingwex/wmemchr.c winsup/mingw/mingwex/wmemcmp.c winsup/mingw/mingwex/wmemcpy.c winsup/mingw/mingwex/wmemmove.c winsup/mingw/mingwex/wmemset.c winsup/mingw/mingwex/wtoll.c winsup/mingw/mkinstalldirs winsup/mingw/moldname.def.in winsup/mingw/msvcrt.def.in winsup/mingw/mthr.c winsup/mingw/mthr_init.c winsup/mingw/mthr_stub.c winsup/mingw/profile/Makefile.in winsup/mingw/profile/configure winsup/mingw/profile/configure.in winsup/mingw/profile/gcrt0.c winsup/mingw/profile/gmon.c winsup/mingw/profile/gmon.h winsup/mingw/profile/mcount.c winsup/mingw/profile/profil.c winsup/mingw/profile/profil.h winsup/mingw/profile/profile.h winsup/mingw/pseudo-reloc-list.c winsup/mingw/pseudo-reloc.c winsup/mingw/readme.txt winsup/mingw/samples/dirent/jamfile winsup/mingw/samples/dirent/test.c winsup/mingw/samples/dirent/wtest.c winsup/mingw/samples/dlltest/dll.c winsup/mingw/samples/dlltest/dll.def winsup/mingw/samples/dlltest/dll.h winsup/mingw/samples/dlltest/exe.c winsup/mingw/samples/dlltest/exe.exp winsup/mingw/samples/dlltest/expexe.c winsup/mingw/samples/dlltest/expexe.def winsup/mingw/samples/dlltest/jamfile winsup/mingw/samples/dlltest/loaddll.c winsup/mingw/samples/dlltest/loadexe.c winsup/mingw/samples/dlltest/readme.txt winsup/mingw/samples/dlltest/silly.cpp winsup/mingw/samples/dlltest/silly.def winsup/mingw/samples/dlltest/silly.exp winsup/mingw/samples/dlltest/silly.h winsup/mingw/samples/dlltest/sillydll.cpp winsup/mingw/samples/filehand/filehand.c winsup/mingw/samples/filehand/jamfile winsup/mingw/samples/filehand/junk.txt winsup/mingw/samples/fixargv/fixargv.c winsup/mingw/samples/fixargv/fixargv.h winsup/mingw/samples/fixargv/readme.txt winsup/mingw/samples/fmode/all.c winsup/mingw/samples/fmode/jamfile winsup/mingw/samples/fmode/readme.txt winsup/mingw/samples/fmode/test.c winsup/mingw/samples/fmode/test2.c winsup/mingw/samples/globbing/glob.c winsup/mingw/samples/globbing/jamfile winsup/mingw/samples/globbing/noglob.c winsup/mingw/samples/globbing/readme.txt winsup/mingw/samples/print/jamfile winsup/mingw/samples/print/prntest.c winsup/mingw/samples/seh/eh3.c winsup/mingw/samples/seh/exutil.c winsup/mingw/samples/seh/exutil.def winsup/mingw/samples/seh/exutil.h winsup/mingw/samples/seh/jamfile winsup/mingw/samples/seh/sehfix.c winsup/mingw/samples/seh/sehsub.c winsup/mingw/samples/seh/sehtest.c winsup/mingw/samples/simpledll/dll.c winsup/mingw/samples/simpledll/dll.cpp winsup/mingw/samples/simpledll/dll.def winsup/mingw/samples/simpledll/exe.c winsup/mingw/samples/simpledll/jamfile winsup/mingw/samples/simpledll/makedll.bat winsup/mingw/samples/test/jamfile winsup/mingw/samples/test/test.c winsup/mingw/samples/wintest/jamfile winsup/mingw/samples/wintest/test.c winsup/mingw/strcasecmp.c winsup/mingw/strncasecmp.c winsup/mingw/test_headers.c winsup/mingw/toascii.c winsup/mingw/txtmode.c winsup/mingw/wcscmpi.c winsup/subauth/ChangeLog winsup/subauth/Makefile.in winsup/subauth/configure winsup/subauth/configure.in winsup/subauth/cygsuba.c winsup/subauth/cygsuba.din winsup/testsuite/ChangeLog winsup/testsuite/Makefile.in winsup/testsuite/README winsup/testsuite/config/default.exp winsup/testsuite/configure winsup/testsuite/configure.in winsup/testsuite/cygrun.c winsup/testsuite/libltp/include/dataascii.h winsup/testsuite/libltp/include/databin.h winsup/testsuite/libltp/include/file_lock.h winsup/testsuite/libltp/include/forker.h winsup/testsuite/libltp/include/open_flags.h winsup/testsuite/libltp/include/pattern.h winsup/testsuite/libltp/include/random_range.h winsup/testsuite/libltp/include/rmobj.h winsup/testsuite/libltp/include/search_path.h winsup/testsuite/libltp/include/str_to_bytes.h winsup/testsuite/libltp/include/string_to_tokens.h winsup/testsuite/libltp/include/test.h winsup/testsuite/libltp/include/tlibio.h winsup/testsuite/libltp/include/usctest.h winsup/testsuite/libltp/include/write_log.h winsup/testsuite/libltp/lib/dataascii.c winsup/testsuite/libltp/lib/databin.c winsup/testsuite/libltp/lib/datapid.c winsup/testsuite/libltp/lib/forker.c winsup/testsuite/libltp/lib/get_high_address.c winsup/testsuite/libltp/lib/libtestsuite.c winsup/testsuite/libltp/lib/open_flags.c winsup/testsuite/libltp/lib/parse_opts.c winsup/testsuite/libltp/lib/pattern.c winsup/testsuite/libltp/lib/rmobj.c winsup/testsuite/libltp/lib/search_path.c winsup/testsuite/libltp/lib/str_to_bytes.c winsup/testsuite/libltp/lib/string_to_tokens.c winsup/testsuite/libltp/lib/tst_res.c winsup/testsuite/libltp/lib/tst_sig.c winsup/testsuite/libltp/lib/tst_tmpdir.c winsup/testsuite/libltp/lib/write_log.c winsup/testsuite/winsup.api/checksignal.c winsup/testsuite/winsup.api/crlf.c winsup/testsuite/winsup.api/devzero.c winsup/testsuite/winsup.api/iospeed.c winsup/testsuite/winsup.api/known_bugs.tcl winsup/testsuite/winsup.api/ltp/access01.c winsup/testsuite/winsup.api/ltp/access03.c winsup/testsuite/winsup.api/ltp/access04.c winsup/testsuite/winsup.api/ltp/access05.c winsup/testsuite/winsup.api/ltp/alarm01.c winsup/testsuite/winsup.api/ltp/alarm02.c winsup/testsuite/winsup.api/ltp/alarm03.c winsup/testsuite/winsup.api/ltp/alarm07.c winsup/testsuite/winsup.api/ltp/asyncio02.c winsup/testsuite/winsup.api/ltp/chdir02.c winsup/testsuite/winsup.api/ltp/chdir04.c winsup/testsuite/winsup.api/ltp/chmod01.c winsup/testsuite/winsup.api/ltp/chmod02.c winsup/testsuite/winsup.api/ltp/chown01.c winsup/testsuite/winsup.api/ltp/close01.c winsup/testsuite/winsup.api/ltp/close02.c winsup/testsuite/winsup.api/ltp/close08.c winsup/testsuite/winsup.api/ltp/creat01.c winsup/testsuite/winsup.api/ltp/creat03.c winsup/testsuite/winsup.api/ltp/creat09.c winsup/testsuite/winsup.api/ltp/dup01.c winsup/testsuite/winsup.api/ltp/dup02.c winsup/testsuite/winsup.api/ltp/dup03.c winsup/testsuite/winsup.api/ltp/dup04.c winsup/testsuite/winsup.api/ltp/dup05.c winsup/testsuite/winsup.api/ltp/execl01.c winsup/testsuite/winsup.api/ltp/execle01.c winsup/testsuite/winsup.api/ltp/execlp01.c winsup/testsuite/winsup.api/ltp/execv01.c winsup/testsuite/winsup.api/ltp/execve01.c winsup/testsuite/winsup.api/ltp/execvp01.c winsup/testsuite/winsup.api/ltp/exit01.c winsup/testsuite/winsup.api/ltp/exit02.c winsup/testsuite/winsup.api/ltp/fchdir01.c winsup/testsuite/winsup.api/ltp/fchdir02.c winsup/testsuite/winsup.api/ltp/fchmod01.c winsup/testsuite/winsup.api/ltp/fchown01.c winsup/testsuite/winsup.api/ltp/fcntl02.c winsup/testsuite/winsup.api/ltp/fcntl03.c winsup/testsuite/winsup.api/ltp/fcntl04.c winsup/testsuite/winsup.api/ltp/fcntl05.c winsup/testsuite/winsup.api/ltp/fcntl07.c winsup/testsuite/winsup.api/ltp/fcntl07B.c winsup/testsuite/winsup.api/ltp/fcntl08.c winsup/testsuite/winsup.api/ltp/fcntl09.c winsup/testsuite/winsup.api/ltp/fcntl10.c winsup/testsuite/winsup.api/ltp/fork01.c winsup/testsuite/winsup.api/ltp/fork02.c winsup/testsuite/winsup.api/ltp/fork03.c winsup/testsuite/winsup.api/ltp/fork04.c winsup/testsuite/winsup.api/ltp/fork06.c winsup/testsuite/winsup.api/ltp/fork07.c winsup/testsuite/winsup.api/ltp/fork09.c winsup/testsuite/winsup.api/ltp/fork10.c winsup/testsuite/winsup.api/ltp/fork11.c winsup/testsuite/winsup.api/ltp/fpathconf01.c winsup/testsuite/winsup.api/ltp/fstat01.c winsup/testsuite/winsup.api/ltp/fstat02.c winsup/testsuite/winsup.api/ltp/fstat03.c winsup/testsuite/winsup.api/ltp/fstat04.c winsup/testsuite/winsup.api/ltp/fsync01.c winsup/testsuite/winsup.api/ltp/ftruncate01.c winsup/testsuite/winsup.api/ltp/ftruncate02.c winsup/testsuite/winsup.api/ltp/ftruncate03.c winsup/testsuite/winsup.api/ltp/getegid01.c winsup/testsuite/winsup.api/ltp/geteuid01.c winsup/testsuite/winsup.api/ltp/getgid01.c winsup/testsuite/winsup.api/ltp/getgid02.c winsup/testsuite/winsup.api/ltp/getgid03.c winsup/testsuite/winsup.api/ltp/getgroups01.c winsup/testsuite/winsup.api/ltp/getgroups02.c winsup/testsuite/winsup.api/ltp/gethostid01.c winsup/testsuite/winsup.api/ltp/gethostname01.c winsup/testsuite/winsup.api/ltp/getpgid01.c winsup/testsuite/winsup.api/ltp/getpgid02.c winsup/testsuite/winsup.api/ltp/getpgrp01.c winsup/testsuite/winsup.api/ltp/getpid01.c winsup/testsuite/winsup.api/ltp/getpid02.c winsup/testsuite/winsup.api/ltp/getppid01.c winsup/testsuite/winsup.api/ltp/getppid02.c winsup/testsuite/winsup.api/ltp/getuid01.c winsup/testsuite/winsup.api/ltp/getuid02.c winsup/testsuite/winsup.api/ltp/getuid03.c winsup/testsuite/winsup.api/ltp/kill01.c winsup/testsuite/winsup.api/ltp/kill02.c winsup/testsuite/winsup.api/ltp/kill03.c winsup/testsuite/winsup.api/ltp/kill04.c winsup/testsuite/winsup.api/ltp/kill09.c winsup/testsuite/winsup.api/ltp/link02.c winsup/testsuite/winsup.api/ltp/link03.c winsup/testsuite/winsup.api/ltp/link04.c winsup/testsuite/winsup.api/ltp/link05.c winsup/testsuite/winsup.api/ltp/lseek01.c winsup/testsuite/winsup.api/ltp/lseek02.c winsup/testsuite/winsup.api/ltp/lseek03.c winsup/testsuite/winsup.api/ltp/lseek04.c winsup/testsuite/winsup.api/ltp/lseek05.c winsup/testsuite/winsup.api/ltp/lseek06.c winsup/testsuite/winsup.api/ltp/lseek07.c winsup/testsuite/winsup.api/ltp/lseek08.c winsup/testsuite/winsup.api/ltp/lseek09.c winsup/testsuite/winsup.api/ltp/lseek10.c winsup/testsuite/winsup.api/ltp/lstat02.c winsup/testsuite/winsup.api/ltp/mkdir01.c winsup/testsuite/winsup.api/ltp/mkdir08.c winsup/testsuite/winsup.api/ltp/mknod01.c winsup/testsuite/winsup.api/ltp/mmap001.c winsup/testsuite/winsup.api/ltp/mmap02.c winsup/testsuite/winsup.api/ltp/mmap03.c winsup/testsuite/winsup.api/ltp/mmap04.c winsup/testsuite/winsup.api/ltp/mmap05.c winsup/testsuite/winsup.api/ltp/mmap06.c winsup/testsuite/winsup.api/ltp/mmap07.c winsup/testsuite/winsup.api/ltp/mmap08.c winsup/testsuite/winsup.api/ltp/munmap01.c winsup/testsuite/winsup.api/ltp/munmap02.c winsup/testsuite/winsup.api/ltp/nice05.c winsup/testsuite/winsup.api/ltp/open02.c winsup/testsuite/winsup.api/ltp/open03.c winsup/testsuite/winsup.api/ltp/pathconf01.c winsup/testsuite/winsup.api/ltp/pause01.c winsup/testsuite/winsup.api/ltp/pipe01.c winsup/testsuite/winsup.api/ltp/pipe08.c winsup/testsuite/winsup.api/ltp/pipe09.c winsup/testsuite/winsup.api/ltp/pipe10.c winsup/testsuite/winsup.api/ltp/pipe11.c winsup/testsuite/winsup.api/ltp/poll01.c winsup/testsuite/winsup.api/ltp/read01.c winsup/testsuite/winsup.api/ltp/read04.c winsup/testsuite/winsup.api/ltp/readdir01.c winsup/testsuite/winsup.api/ltp/readlink01.c winsup/testsuite/winsup.api/ltp/readlink02.c winsup/testsuite/winsup.api/ltp/readlink03.c winsup/testsuite/winsup.api/ltp/rename01.c winsup/testsuite/winsup.api/ltp/rename02.c winsup/testsuite/winsup.api/ltp/rename08.c winsup/testsuite/winsup.api/ltp/rename10.c winsup/testsuite/winsup.api/ltp/rmdir01.c winsup/testsuite/winsup.api/ltp/rmdir04.c winsup/testsuite/winsup.api/ltp/rmdir05.c winsup/testsuite/winsup.api/ltp/sbrk01.c winsup/testsuite/winsup.api/ltp/select01.c winsup/testsuite/winsup.api/ltp/select02.c winsup/testsuite/winsup.api/ltp/select03.c winsup/testsuite/winsup.api/ltp/setgid01.c winsup/testsuite/winsup.api/ltp/setgroups01.c winsup/testsuite/winsup.api/ltp/setpgid01.c winsup/testsuite/winsup.api/ltp/setregid01.c winsup/testsuite/winsup.api/ltp/setreuid01.c winsup/testsuite/winsup.api/ltp/setuid01.c winsup/testsuite/winsup.api/ltp/setuid02.c winsup/testsuite/winsup.api/ltp/signal03.c winsup/testsuite/winsup.api/ltp/stat01.c winsup/testsuite/winsup.api/ltp/stat02.c winsup/testsuite/winsup.api/ltp/stat03.c winsup/testsuite/winsup.api/ltp/stat05.c winsup/testsuite/winsup.api/ltp/stat06.c winsup/testsuite/winsup.api/ltp/symlink01.c winsup/testsuite/winsup.api/ltp/symlink02.c winsup/testsuite/winsup.api/ltp/symlink03.c winsup/testsuite/winsup.api/ltp/symlink04.c winsup/testsuite/winsup.api/ltp/symlink05.c winsup/testsuite/winsup.api/ltp/sync01.c winsup/testsuite/winsup.api/ltp/sync02.c winsup/testsuite/winsup.api/ltp/time01.c winsup/testsuite/winsup.api/ltp/time02.c winsup/testsuite/winsup.api/ltp/times01.c winsup/testsuite/winsup.api/ltp/times02.c winsup/testsuite/winsup.api/ltp/times03.c winsup/testsuite/winsup.api/ltp/truncate01.c winsup/testsuite/winsup.api/ltp/truncate02.c winsup/testsuite/winsup.api/ltp/ulimit01.c winsup/testsuite/winsup.api/ltp/umask01.c winsup/testsuite/winsup.api/ltp/umask02.c winsup/testsuite/winsup.api/ltp/umask03.c winsup/testsuite/winsup.api/ltp/uname01.c winsup/testsuite/winsup.api/ltp/unlink05.c winsup/testsuite/winsup.api/ltp/unlink06.c winsup/testsuite/winsup.api/ltp/unlink07.c winsup/testsuite/winsup.api/ltp/unlink08.c winsup/testsuite/winsup.api/ltp/vfork01.c winsup/testsuite/winsup.api/ltp/wait02.c winsup/testsuite/winsup.api/ltp/wait401.c winsup/testsuite/winsup.api/ltp/wait402.c winsup/testsuite/winsup.api/ltp/write01.c winsup/testsuite/winsup.api/ltp/write02.c winsup/testsuite/winsup.api/ltp/write03.c winsup/testsuite/winsup.api/mmaptest01.c winsup/testsuite/winsup.api/mmaptest02.c winsup/testsuite/winsup.api/mmaptest03.c winsup/testsuite/winsup.api/mmaptest04.c winsup/testsuite/winsup.api/msgtest.c winsup/testsuite/winsup.api/nullgetcwd.c winsup/testsuite/winsup.api/pthread/cancel1.c winsup/testsuite/winsup.api/pthread/cancel10.c winsup/testsuite/winsup.api/pthread/cancel11.c winsup/testsuite/winsup.api/pthread/cancel12.c winsup/testsuite/winsup.api/pthread/cancel2.c winsup/testsuite/winsup.api/pthread/cancel3.c winsup/testsuite/winsup.api/pthread/cancel4.c winsup/testsuite/winsup.api/pthread/cancel5.c winsup/testsuite/winsup.api/pthread/cancel6.c winsup/testsuite/winsup.api/pthread/cancel7.c winsup/testsuite/winsup.api/pthread/cancel8.c winsup/testsuite/winsup.api/pthread/cancel9.c winsup/testsuite/winsup.api/pthread/cleanup2.c winsup/testsuite/winsup.api/pthread/cleanup3.c winsup/testsuite/winsup.api/pthread/condvar1.c winsup/testsuite/winsup.api/pthread/condvar2.c winsup/testsuite/winsup.api/pthread/condvar2_1.c winsup/testsuite/winsup.api/pthread/condvar3.c winsup/testsuite/winsup.api/pthread/condvar3_1.c winsup/testsuite/winsup.api/pthread/condvar3_2.c winsup/testsuite/winsup.api/pthread/condvar3_3.c winsup/testsuite/winsup.api/pthread/condvar4.c winsup/testsuite/winsup.api/pthread/condvar5.c winsup/testsuite/winsup.api/pthread/condvar6.c winsup/testsuite/winsup.api/pthread/condvar7.c winsup/testsuite/winsup.api/pthread/condvar8.c winsup/testsuite/winsup.api/pthread/condvar9.c winsup/testsuite/winsup.api/pthread/count1.c winsup/testsuite/winsup.api/pthread/create1.c winsup/testsuite/winsup.api/pthread/create2.c winsup/testsuite/winsup.api/pthread/equal1.c winsup/testsuite/winsup.api/pthread/exit1.c winsup/testsuite/winsup.api/pthread/exit2.c winsup/testsuite/winsup.api/pthread/exit3.c winsup/testsuite/winsup.api/pthread/inherit1.c winsup/testsuite/winsup.api/pthread/join0.c winsup/testsuite/winsup.api/pthread/join1.c winsup/testsuite/winsup.api/pthread/join2.c winsup/testsuite/winsup.api/pthread/mainthreadexits.c winsup/testsuite/winsup.api/pthread/mutex1.c winsup/testsuite/winsup.api/pthread/mutex1d.c winsup/testsuite/winsup.api/pthread/mutex1e.c winsup/testsuite/winsup.api/pthread/mutex1n.c winsup/testsuite/winsup.api/pthread/mutex1r.c winsup/testsuite/winsup.api/pthread/mutex2.c winsup/testsuite/winsup.api/pthread/mutex3.c winsup/testsuite/winsup.api/pthread/mutex4.c winsup/testsuite/winsup.api/pthread/mutex5.c winsup/testsuite/winsup.api/pthread/mutex6d.c winsup/testsuite/winsup.api/pthread/mutex6e.c winsup/testsuite/winsup.api/pthread/mutex6n.c winsup/testsuite/winsup.api/pthread/mutex6r.c winsup/testsuite/winsup.api/pthread/mutex7.c winsup/testsuite/winsup.api/pthread/mutex7d.c winsup/testsuite/winsup.api/pthread/mutex7e.c winsup/testsuite/winsup.api/pthread/mutex7n.c winsup/testsuite/winsup.api/pthread/mutex7r.c winsup/testsuite/winsup.api/pthread/once1.c winsup/testsuite/winsup.api/pthread/priority1.c winsup/testsuite/winsup.api/pthread/priority2.c winsup/testsuite/winsup.api/pthread/rwlock1.c winsup/testsuite/winsup.api/pthread/rwlock2.c winsup/testsuite/winsup.api/pthread/rwlock3.c winsup/testsuite/winsup.api/pthread/rwlock4.c winsup/testsuite/winsup.api/pthread/rwlock5.c winsup/testsuite/winsup.api/pthread/rwlock6.c winsup/testsuite/winsup.api/pthread/rwlock7.c winsup/testsuite/winsup.api/pthread/self1.c winsup/testsuite/winsup.api/pthread/self2.c winsup/testsuite/winsup.api/pthread/test.h winsup/testsuite/winsup.api/pthread/threadidafterfork.c winsup/testsuite/winsup.api/pthread/tsd1.c winsup/testsuite/winsup.api/samples/sample-fail.c winsup/testsuite/winsup.api/samples/sample-miscompile.c winsup/testsuite/winsup.api/samples/sample-pass.c winsup/testsuite/winsup.api/semtest.c winsup/testsuite/winsup.api/shmtest.c winsup/testsuite/winsup.api/sigchld.c winsup/testsuite/winsup.api/signal-into-win32-api.c winsup/testsuite/winsup.api/systemcall.c winsup/testsuite/winsup.api/waitpid.c winsup/testsuite/winsup.api/winsup.exp winsup/utils/ChangeLog winsup/utils/ChangeLog-2000 winsup/utils/Makefile.in winsup/utils/aclocal.m4 winsup/utils/configure winsup/utils/configure.in winsup/utils/cygcheck.cc winsup/utils/cygpath.cc winsup/utils/dump_setup.cc winsup/utils/dumper.cc winsup/utils/dumper.h winsup/utils/getfacl.c winsup/utils/ipcrm.c winsup/utils/ipcs.c winsup/utils/kill.cc winsup/utils/mkgroup.c winsup/utils/mkpasswd.c winsup/utils/module_info.cc winsup/utils/mount.cc winsup/utils/parse_pe.cc winsup/utils/passwd.c winsup/utils/path.cc winsup/utils/path.h winsup/utils/ps.cc winsup/utils/regtool.cc winsup/utils/setfacl.c winsup/utils/ssp.c winsup/utils/ssp.txt winsup/utils/strace.cc winsup/utils/umount.cc winsup/utils/utils.sgml winsup/w32api/CONTRIBUTIONS winsup/w32api/ChangeLog winsup/w32api/Makefile.in winsup/w32api/README.w32api winsup/w32api/TODO winsup/w32api/config.guess winsup/w32api/config.sub winsup/w32api/configure winsup/w32api/configure.in winsup/w32api/include/GL/gl.h winsup/w32api/include/GL/glext.h winsup/w32api/include/GL/glu.h winsup/w32api/include/accctrl.h winsup/w32api/include/aclapi.h winsup/w32api/include/afxres.h winsup/w32api/include/basetsd.h winsup/w32api/include/basetyps.h winsup/w32api/include/cderr.h winsup/w32api/include/cguid.h winsup/w32api/include/comcat.h winsup/w32api/include/commctrl.h winsup/w32api/include/commdlg.h winsup/w32api/include/cpl.h winsup/w32api/include/cplext.h winsup/w32api/include/custcntl.h winsup/w32api/include/dbt.h winsup/w32api/include/dde.h winsup/w32api/include/ddeml.h winsup/w32api/include/ddk/atm.h winsup/w32api/include/ddk/batclass.h winsup/w32api/include/ddk/cfg.h winsup/w32api/include/ddk/cfgmgr32.h winsup/w32api/include/ddk/d4drvif.h winsup/w32api/include/ddk/d4iface.h winsup/w32api/include/ddk/ddkmapi.h winsup/w32api/include/ddk/hidclass.h winsup/w32api/include/ddk/hidpi.h winsup/w32api/include/ddk/hidusage.h winsup/w32api/include/ddk/mcd.h winsup/w32api/include/ddk/miniport.h winsup/w32api/include/ddk/minitape.h winsup/w32api/include/ddk/mountdev.h winsup/w32api/include/ddk/mountmgr.h winsup/w32api/include/ddk/ndis.h winsup/w32api/include/ddk/ndisguid.h winsup/w32api/include/ddk/ndistapi.h winsup/w32api/include/ddk/ndiswan.h winsup/w32api/include/ddk/netevent.h winsup/w32api/include/ddk/netpnp.h winsup/w32api/include/ddk/newdev.h winsup/w32api/include/ddk/ntapi.h winsup/w32api/include/ddk/ntdd8042.h winsup/w32api/include/ddk/ntddbeep.h winsup/w32api/include/ddk/ntddcdrm.h winsup/w32api/include/ddk/ntddcdvd.h winsup/w32api/include/ddk/ntddchgr.h winsup/w32api/include/ddk/ntdddisk.h winsup/w32api/include/ddk/ntddk.h winsup/w32api/include/ddk/ntddkbd.h winsup/w32api/include/ddk/ntddmou.h winsup/w32api/include/ddk/ntddndis.h winsup/w32api/include/ddk/ntddpar.h winsup/w32api/include/ddk/ntddpcm.h winsup/w32api/include/ddk/ntddscsi.h winsup/w32api/include/ddk/ntddser.h winsup/w32api/include/ddk/ntddstor.h winsup/w32api/include/ddk/ntddtape.h winsup/w32api/include/ddk/ntddtdi.h winsup/w32api/include/ddk/ntddvdeo.h winsup/w32api/include/ddk/ntddvol.h winsup/w32api/include/ddk/ntifs.h winsup/w32api/include/ddk/ntpoapi.h winsup/w32api/include/ddk/ntstatus.h winsup/w32api/include/ddk/parallel.h winsup/w32api/include/ddk/pfhook.h winsup/w32api/include/ddk/poclass.h winsup/w32api/include/ddk/scsi.h winsup/w32api/include/ddk/scsiscan.h winsup/w32api/include/ddk/scsiwmi.h winsup/w32api/include/ddk/smbus.h winsup/w32api/include/ddk/srb.h winsup/w32api/include/ddk/storport.h winsup/w32api/include/ddk/tdi.h winsup/w32api/include/ddk/tdiinfo.h winsup/w32api/include/ddk/tdikrnl.h winsup/w32api/include/ddk/tdistat.h winsup/w32api/include/ddk/tvout.h winsup/w32api/include/ddk/upssvc.h winsup/w32api/include/ddk/usb.h winsup/w32api/include/ddk/usb100.h winsup/w32api/include/ddk/usbcamdi.h winsup/w32api/include/ddk/usbdi.h winsup/w32api/include/ddk/usbioctl.h winsup/w32api/include/ddk/usbiodef.h winsup/w32api/include/ddk/usbscan.h winsup/w32api/include/ddk/usbuser.h winsup/w32api/include/ddk/video.h winsup/w32api/include/ddk/videoagp.h winsup/w32api/include/ddk/win2k.h winsup/w32api/include/ddk/winddi.h winsup/w32api/include/ddk/winddk.h winsup/w32api/include/ddk/winnt4.h winsup/w32api/include/ddk/winxp.h winsup/w32api/include/ddk/ws2san.h winsup/w32api/include/ddk/xfilter.h winsup/w32api/include/dhcpcsdk.h winsup/w32api/include/dlgs.h winsup/w32api/include/docobj.h winsup/w32api/include/errorrep.h winsup/w32api/include/exdisp.h winsup/w32api/include/exdispid.h winsup/w32api/include/httpext.h winsup/w32api/include/idispids.h winsup/w32api/include/imagehlp.h winsup/w32api/include/imm.h winsup/w32api/include/initguid.h winsup/w32api/include/intshcut.h winsup/w32api/include/ipexport.h winsup/w32api/include/iphlpapi.h winsup/w32api/include/ipifcons.h winsup/w32api/include/iprtrmib.h winsup/w32api/include/iptypes.h winsup/w32api/include/isguids.h winsup/w32api/include/largeint.h winsup/w32api/include/lm.h winsup/w32api/include/lmaccess.h winsup/w32api/include/lmalert.h winsup/w32api/include/lmapibuf.h winsup/w32api/include/lmat.h winsup/w32api/include/lmaudit.h winsup/w32api/include/lmbrowsr.h winsup/w32api/include/lmchdev.h winsup/w32api/include/lmconfig.h winsup/w32api/include/lmcons.h winsup/w32api/include/lmerr.h winsup/w32api/include/lmerrlog.h winsup/w32api/include/lmmsg.h winsup/w32api/include/lmremutl.h winsup/w32api/include/lmrepl.h winsup/w32api/include/lmserver.h winsup/w32api/include/lmshare.h winsup/w32api/include/lmsname.h winsup/w32api/include/lmstats.h winsup/w32api/include/lmsvc.h winsup/w32api/include/lmuse.h winsup/w32api/include/lmuseflg.h winsup/w32api/include/lmwksta.h winsup/w32api/include/lzexpand.h winsup/w32api/include/mapi.h winsup/w32api/include/mciavi.h winsup/w32api/include/mcx.h winsup/w32api/include/mgmtapi.h winsup/w32api/include/mmsystem.h winsup/w32api/include/mshtml.h winsup/w32api/include/mswsock.h winsup/w32api/include/nb30.h winsup/w32api/include/nddeapi.h winsup/w32api/include/nspapi.h winsup/w32api/include/ntdef.h winsup/w32api/include/ntdll.h winsup/w32api/include/ntldap.h winsup/w32api/include/ntsecapi.h winsup/w32api/include/ntsecpkg.h winsup/w32api/include/oaidl.h winsup/w32api/include/objbase.h winsup/w32api/include/objfwd.h winsup/w32api/include/objidl.h winsup/w32api/include/ocidl.h winsup/w32api/include/odbcinst.h winsup/w32api/include/ole.h winsup/w32api/include/ole2.h winsup/w32api/include/ole2ver.h winsup/w32api/include/oleacc.h winsup/w32api/include/oleauto.h winsup/w32api/include/olectl.h winsup/w32api/include/olectlid.h winsup/w32api/include/oledlg.h winsup/w32api/include/oleidl.h winsup/w32api/include/pbt.h winsup/w32api/include/poppack.h winsup/w32api/include/powrprof.h winsup/w32api/include/prsht.h winsup/w32api/include/psapi.h winsup/w32api/include/pshpack1.h winsup/w32api/include/pshpack2.h winsup/w32api/include/pshpack4.h winsup/w32api/include/pshpack8.h winsup/w32api/include/rapi.h winsup/w32api/include/ras.h winsup/w32api/include/rasdlg.h winsup/w32api/include/raserror.h winsup/w32api/include/rassapi.h winsup/w32api/include/regstr.h winsup/w32api/include/richedit.h winsup/w32api/include/richole.h winsup/w32api/include/rpc.h winsup/w32api/include/rpcdce.h winsup/w32api/include/rpcdce2.h winsup/w32api/include/rpcdcep.h winsup/w32api/include/rpcndr.h winsup/w32api/include/rpcnsi.h winsup/w32api/include/rpcnsip.h winsup/w32api/include/rpcnterr.h winsup/w32api/include/rpcproxy.h winsup/w32api/include/schannel.h winsup/w32api/include/schnlsp.h winsup/w32api/include/scrnsave.h winsup/w32api/include/secext.h winsup/w32api/include/security.h winsup/w32api/include/servprov.h winsup/w32api/include/setupapi.h winsup/w32api/include/shellapi.h winsup/w32api/include/shlguid.h winsup/w32api/include/shlobj.h winsup/w32api/include/shlwapi.h winsup/w32api/include/snmp.h winsup/w32api/include/sql.h winsup/w32api/include/sqlext.h winsup/w32api/include/sqltypes.h winsup/w32api/include/sqlucode.h winsup/w32api/include/sspi.h winsup/w32api/include/subauth.h winsup/w32api/include/svcguid.h winsup/w32api/include/tlhelp32.h winsup/w32api/include/tmschema.h winsup/w32api/include/unknwn.h winsup/w32api/include/userenv.h winsup/w32api/include/uxtheme.h winsup/w32api/include/vfw.h winsup/w32api/include/w32api.h winsup/w32api/include/winable.h winsup/w32api/include/winbase.h winsup/w32api/include/winber.h winsup/w32api/include/wincon.h winsup/w32api/include/wincrypt.h winsup/w32api/include/windef.h winsup/w32api/include/windows.h winsup/w32api/include/windowsx.h winsup/w32api/include/winerror.h winsup/w32api/include/wingdi.h winsup/w32api/include/wininet.h winsup/w32api/include/winioctl.h winsup/w32api/include/winldap.h winsup/w32api/include/winnetwk.h winsup/w32api/include/winnls.h winsup/w32api/include/winnt.h winsup/w32api/include/winperf.h winsup/w32api/include/winreg.h winsup/w32api/include/winresrc.h winsup/w32api/include/winsnmp.h winsup/w32api/include/winsock.h winsup/w32api/include/winsock2.h winsup/w32api/include/winspool.h winsup/w32api/include/winsvc.h winsup/w32api/include/winuser.h winsup/w32api/include/winver.h winsup/w32api/include/ws2spi.h winsup/w32api/include/ws2tcpip.h winsup/w32api/include/wsahelp.h winsup/w32api/include/wsipx.h winsup/w32api/include/wsnetbs.h winsup/w32api/include/wtypes.h winsup/w32api/include/zmouse.h winsup/w32api/install-sh winsup/w32api/lib/Makefile.in winsup/w32api/lib/advapi32.def winsup/w32api/lib/avicap32.def winsup/w32api/lib/avifil32.def winsup/w32api/lib/cap.def winsup/w32api/lib/comctl32.def winsup/w32api/lib/comdlg32.def winsup/w32api/lib/crypt32.def winsup/w32api/lib/ctl3d32.def winsup/w32api/lib/d3dim.def winsup/w32api/lib/d3drm.def winsup/w32api/lib/d3dxof.def winsup/w32api/lib/ddk/Makefile.in winsup/w32api/lib/ddk/apcups.def winsup/w32api/lib/ddk/cfgmgr32.def winsup/w32api/lib/ddk/dxapi.def winsup/w32api/lib/ddk/hal.def winsup/w32api/lib/ddk/hid.def winsup/w32api/lib/ddk/hidparse.def winsup/w32api/lib/ddk/mcd.def winsup/w32api/lib/ddk/ndis.def winsup/w32api/lib/ddk/ntoskrnl.def winsup/w32api/lib/ddk/scsiport.def winsup/w32api/lib/ddk/tdi.def winsup/w32api/lib/ddk/usbcamd.def winsup/w32api/lib/ddk/usbcamd2.def winsup/w32api/lib/ddk/videoprt.def winsup/w32api/lib/ddk/win32k.def winsup/w32api/lib/ddraw.def winsup/w32api/lib/dhcpcsvc.def winsup/w32api/lib/dinput.c winsup/w32api/lib/dinput.def winsup/w32api/lib/dlcapi.def winsup/w32api/lib/dplayx.def winsup/w32api/lib/dsetup.def winsup/w32api/lib/dsound.def winsup/w32api/lib/dxguid.c winsup/w32api/lib/faultrep.def winsup/w32api/lib/gdi32.def winsup/w32api/lib/glaux.def winsup/w32api/lib/glu32.def winsup/w32api/lib/glut.def winsup/w32api/lib/glut32.def winsup/w32api/lib/igmpagnt.def winsup/w32api/lib/imagehlp.def winsup/w32api/lib/imm32.def winsup/w32api/lib/iphlpapi.def winsup/w32api/lib/kernel32.c winsup/w32api/lib/kernel32.def winsup/w32api/lib/largeint.c winsup/w32api/lib/lz32.def winsup/w32api/lib/mapi32.def winsup/w32api/lib/mfcuia32.def winsup/w32api/lib/mgmtapi.def winsup/w32api/lib/mpr.def winsup/w32api/lib/msacm32.def winsup/w32api/lib/mshtml-uuid.c winsup/w32api/lib/msimg32.def winsup/w32api/lib/msvcp60.def winsup/w32api/lib/msvfw32.def winsup/w32api/lib/mswsock.def winsup/w32api/lib/nddeapi.def winsup/w32api/lib/netapi32.def winsup/w32api/lib/ntdll.def winsup/w32api/lib/odbc32.def winsup/w32api/lib/odbccp32.def winsup/w32api/lib/ole32.def winsup/w32api/lib/oleacc.def winsup/w32api/lib/oleaut32.def winsup/w32api/lib/olecli32.def winsup/w32api/lib/oledlg.def winsup/w32api/lib/olepro32.def winsup/w32api/lib/olesvr32.def winsup/w32api/lib/opengl32.def winsup/w32api/lib/penwin32.def winsup/w32api/lib/pkpd32.def winsup/w32api/lib/powrprof.def winsup/w32api/lib/psapi.def winsup/w32api/lib/rapi.def winsup/w32api/lib/rasapi32.def winsup/w32api/lib/rasdlg.def winsup/w32api/lib/res.rc winsup/w32api/lib/rpcdce4.def winsup/w32api/lib/rpcns4.def winsup/w32api/lib/rpcrt4.def winsup/w32api/lib/scrnsave.c winsup/w32api/lib/secur32.def winsup/w32api/lib/setupapi.def winsup/w32api/lib/shell32.c winsup/w32api/lib/shell32.def winsup/w32api/lib/shfolder.def winsup/w32api/lib/shlwapi.def winsup/w32api/lib/snmpapi.def winsup/w32api/lib/svrapi.def winsup/w32api/lib/tapi32.def winsup/w32api/lib/test.c winsup/w32api/lib/th32.def winsup/w32api/lib/thunk32.def winsup/w32api/lib/url.def winsup/w32api/lib/user32.def winsup/w32api/lib/userenv.def winsup/w32api/lib/uuid.c winsup/w32api/lib/uxtheme.def winsup/w32api/lib/vdmdbg.def winsup/w32api/lib/version.def winsup/w32api/lib/vfw32.mri winsup/w32api/lib/win32spl.def winsup/w32api/lib/wininet.def winsup/w32api/lib/winmm.def winsup/w32api/lib/winspool.def winsup/w32api/lib/winstrm.def winsup/w32api/lib/wldap32.def winsup/w32api/lib/wow32.def winsup/w32api/lib/ws2_32.def winsup/w32api/lib/wsnmp32.def winsup/w32api/lib/wsock32.def winsup/w32api/lib/wst.def --- winsup/testsuite/winsup.api/checksignal.c | 76 - winsup/testsuite/winsup.api/crlf.c | 527 ----- winsup/testsuite/winsup.api/devzero.c | 115 -- winsup/testsuite/winsup.api/iospeed.c | 115 -- winsup/testsuite/winsup.api/known_bugs.tcl | 8 - winsup/testsuite/winsup.api/ltp/access01.c | 300 --- winsup/testsuite/winsup.api/ltp/access03.c | 506 ----- winsup/testsuite/winsup.api/ltp/access04.c | 241 --- winsup/testsuite/winsup.api/ltp/access05.c | 424 ---- winsup/testsuite/winsup.api/ltp/alarm01.c | 226 --- winsup/testsuite/winsup.api/ltp/alarm02.c | 240 --- winsup/testsuite/winsup.api/ltp/alarm03.c | 229 --- winsup/testsuite/winsup.api/ltp/alarm07.c | 201 -- winsup/testsuite/winsup.api/ltp/asyncio02.c | 364 ---- winsup/testsuite/winsup.api/ltp/chdir02.c | 219 --- winsup/testsuite/winsup.api/ltp/chdir04.c | 188 -- winsup/testsuite/winsup.api/ltp/chmod01.c | 230 --- winsup/testsuite/winsup.api/ltp/chmod02.c | 260 --- winsup/testsuite/winsup.api/ltp/chown01.c | 244 --- winsup/testsuite/winsup.api/ltp/close01.c | 201 -- winsup/testsuite/winsup.api/ltp/close02.c | 143 -- winsup/testsuite/winsup.api/ltp/close08.c | 241 --- winsup/testsuite/winsup.api/ltp/creat01.c | 207 -- winsup/testsuite/winsup.api/ltp/creat03.c | 154 -- winsup/testsuite/winsup.api/ltp/creat09.c | 246 --- winsup/testsuite/winsup.api/ltp/dup01.c | 261 --- winsup/testsuite/winsup.api/ltp/dup02.c | 246 --- winsup/testsuite/winsup.api/ltp/dup03.c | 291 --- winsup/testsuite/winsup.api/ltp/dup04.c | 297 --- winsup/testsuite/winsup.api/ltp/dup05.c | 266 --- winsup/testsuite/winsup.api/ltp/execl01.c | 258 --- winsup/testsuite/winsup.api/ltp/execle01.c | 257 --- winsup/testsuite/winsup.api/ltp/execlp01.c | 256 --- winsup/testsuite/winsup.api/ltp/execv01.c | 254 --- winsup/testsuite/winsup.api/ltp/execve01.c | 258 --- winsup/testsuite/winsup.api/ltp/execvp01.c | 257 --- winsup/testsuite/winsup.api/ltp/exit01.c | 165 -- winsup/testsuite/winsup.api/ltp/exit02.c | 228 --- winsup/testsuite/winsup.api/ltp/fchdir01.c | 249 --- winsup/testsuite/winsup.api/ltp/fchdir02.c | 160 -- winsup/testsuite/winsup.api/ltp/fchmod01.c | 241 --- winsup/testsuite/winsup.api/ltp/fchown01.c | 234 --- winsup/testsuite/winsup.api/ltp/fcntl02.c | 244 --- winsup/testsuite/winsup.api/ltp/fcntl03.c | 240 --- winsup/testsuite/winsup.api/ltp/fcntl04.c | 239 --- winsup/testsuite/winsup.api/ltp/fcntl05.c | 249 --- winsup/testsuite/winsup.api/ltp/fcntl07.c | 423 ---- winsup/testsuite/winsup.api/ltp/fcntl07B.c | 422 ---- winsup/testsuite/winsup.api/ltp/fcntl08.c | 250 --- winsup/testsuite/winsup.api/ltp/fcntl09.c | 278 --- winsup/testsuite/winsup.api/ltp/fcntl10.c | 284 --- winsup/testsuite/winsup.api/ltp/fork01.c | 316 --- winsup/testsuite/winsup.api/ltp/fork02.c | 139 -- winsup/testsuite/winsup.api/ltp/fork03.c | 165 -- winsup/testsuite/winsup.api/ltp/fork04.c | 403 ---- winsup/testsuite/winsup.api/ltp/fork06.c | 153 -- winsup/testsuite/winsup.api/ltp/fork07.c | 200 -- winsup/testsuite/winsup.api/ltp/fork09.c | 229 --- winsup/testsuite/winsup.api/ltp/fork10.c | 216 --- winsup/testsuite/winsup.api/ltp/fork11.c | 141 -- winsup/testsuite/winsup.api/ltp/fpathconf01.c | 256 --- winsup/testsuite/winsup.api/ltp/fstat01.c | 237 --- winsup/testsuite/winsup.api/ltp/fstat02.c | 244 --- winsup/testsuite/winsup.api/ltp/fstat03.c | 189 -- winsup/testsuite/winsup.api/ltp/fstat04.c | 244 --- winsup/testsuite/winsup.api/ltp/fsync01.c | 248 --- winsup/testsuite/winsup.api/ltp/ftruncate01.c | 244 --- winsup/testsuite/winsup.api/ltp/ftruncate02.c | 313 --- winsup/testsuite/winsup.api/ltp/ftruncate03.c | 324 ---- winsup/testsuite/winsup.api/ltp/getegid01.c | 226 --- winsup/testsuite/winsup.api/ltp/geteuid01.c | 226 --- winsup/testsuite/winsup.api/ltp/getgid01.c | 219 --- winsup/testsuite/winsup.api/ltp/getgid02.c | 159 -- winsup/testsuite/winsup.api/ltp/getgid03.c | 158 -- winsup/testsuite/winsup.api/ltp/getgroups01.c | 314 --- winsup/testsuite/winsup.api/ltp/getgroups02.c | 226 --- winsup/testsuite/winsup.api/ltp/gethostid01.c | 224 --- winsup/testsuite/winsup.api/ltp/gethostname01.c | 226 --- winsup/testsuite/winsup.api/ltp/getpgid01.c | 236 --- winsup/testsuite/winsup.api/ltp/getpgid02.c | 172 -- winsup/testsuite/winsup.api/ltp/getpgrp01.c | 219 --- winsup/testsuite/winsup.api/ltp/getpid01.c | 217 --- winsup/testsuite/winsup.api/ltp/getpid02.c | 186 -- winsup/testsuite/winsup.api/ltp/getppid01.c | 219 --- winsup/testsuite/winsup.api/ltp/getppid02.c | 148 -- winsup/testsuite/winsup.api/ltp/getuid01.c | 219 --- winsup/testsuite/winsup.api/ltp/getuid02.c | 137 -- winsup/testsuite/winsup.api/ltp/getuid03.c | 138 -- winsup/testsuite/winsup.api/ltp/kill01.c | 162 -- winsup/testsuite/winsup.api/ltp/kill02.c | 857 --------- winsup/testsuite/winsup.api/ltp/kill03.c | 170 -- winsup/testsuite/winsup.api/ltp/kill04.c | 181 -- winsup/testsuite/winsup.api/ltp/kill09.c | 258 --- winsup/testsuite/winsup.api/ltp/link02.c | 263 --- winsup/testsuite/winsup.api/ltp/link03.c | 330 ---- winsup/testsuite/winsup.api/ltp/link04.c | 426 ---- winsup/testsuite/winsup.api/ltp/link05.c | 351 ---- winsup/testsuite/winsup.api/ltp/lseek01.c | 255 --- winsup/testsuite/winsup.api/ltp/lseek02.c | 242 --- winsup/testsuite/winsup.api/ltp/lseek03.c | 289 --- winsup/testsuite/winsup.api/ltp/lseek04.c | 256 --- winsup/testsuite/winsup.api/ltp/lseek05.c | 252 --- winsup/testsuite/winsup.api/ltp/lseek06.c | 235 --- winsup/testsuite/winsup.api/ltp/lseek07.c | 286 --- winsup/testsuite/winsup.api/ltp/lseek08.c | 240 --- winsup/testsuite/winsup.api/ltp/lseek09.c | 266 --- winsup/testsuite/winsup.api/ltp/lseek10.c | 344 ---- winsup/testsuite/winsup.api/ltp/lstat02.c | 253 --- winsup/testsuite/winsup.api/ltp/mkdir01.c | 270 --- winsup/testsuite/winsup.api/ltp/mkdir08.c | 235 --- winsup/testsuite/winsup.api/ltp/mknod01.c | 273 --- winsup/testsuite/winsup.api/ltp/mmap001.c | 203 -- winsup/testsuite/winsup.api/ltp/mmap02.c | 291 --- winsup/testsuite/winsup.api/ltp/mmap03.c | 290 --- winsup/testsuite/winsup.api/ltp/mmap04.c | 291 --- winsup/testsuite/winsup.api/ltp/mmap05.c | 301 --- winsup/testsuite/winsup.api/ltp/mmap06.c | 234 --- winsup/testsuite/winsup.api/ltp/mmap07.c | 233 --- winsup/testsuite/winsup.api/ltp/mmap08.c | 234 --- winsup/testsuite/winsup.api/ltp/munmap01.c | 281 --- winsup/testsuite/winsup.api/ltp/munmap02.c | 306 --- winsup/testsuite/winsup.api/ltp/nice05.c | 219 --- winsup/testsuite/winsup.api/ltp/open02.c | 146 -- winsup/testsuite/winsup.api/ltp/open03.c | 243 --- winsup/testsuite/winsup.api/ltp/pathconf01.c | 245 --- winsup/testsuite/winsup.api/ltp/pause01.c | 229 --- winsup/testsuite/winsup.api/ltp/pipe01.c | 156 -- winsup/testsuite/winsup.api/ltp/pipe08.c | 158 -- winsup/testsuite/winsup.api/ltp/pipe09.c | 230 --- winsup/testsuite/winsup.api/ltp/pipe10.c | 167 -- winsup/testsuite/winsup.api/ltp/pipe11.c | 227 --- winsup/testsuite/winsup.api/ltp/poll01.c | 250 --- winsup/testsuite/winsup.api/ltp/read01.c | 280 --- winsup/testsuite/winsup.api/ltp/read04.c | 174 -- winsup/testsuite/winsup.api/ltp/readdir01.c | 350 ---- winsup/testsuite/winsup.api/ltp/readlink01.c | 229 --- winsup/testsuite/winsup.api/ltp/readlink02.c | 244 --- winsup/testsuite/winsup.api/ltp/readlink03.c | 360 ---- winsup/testsuite/winsup.api/ltp/rename01.c | 263 --- winsup/testsuite/winsup.api/ltp/rename02.c | 251 --- winsup/testsuite/winsup.api/ltp/rename08.c | 205 -- winsup/testsuite/winsup.api/ltp/rename10.c | 203 -- winsup/testsuite/winsup.api/ltp/rmdir01.c | 189 -- winsup/testsuite/winsup.api/ltp/rmdir04.c | 236 --- winsup/testsuite/winsup.api/ltp/rmdir05.c | 447 ----- winsup/testsuite/winsup.api/ltp/sbrk01.c | 279 --- winsup/testsuite/winsup.api/ltp/select01.c | 276 --- winsup/testsuite/winsup.api/ltp/select02.c | 268 --- winsup/testsuite/winsup.api/ltp/select03.c | 282 --- winsup/testsuite/winsup.api/ltp/setgid01.c | 219 --- winsup/testsuite/winsup.api/ltp/setgroups01.c | 228 --- winsup/testsuite/winsup.api/ltp/setpgid01.c | 238 --- winsup/testsuite/winsup.api/ltp/setregid01.c | 338 ---- winsup/testsuite/winsup.api/ltp/setreuid01.c | 338 ---- winsup/testsuite/winsup.api/ltp/setuid01.c | 225 --- winsup/testsuite/winsup.api/ltp/setuid02.c | 240 --- winsup/testsuite/winsup.api/ltp/signal03.c | 663 ------- winsup/testsuite/winsup.api/ltp/stat01.c | 267 --- winsup/testsuite/winsup.api/ltp/stat02.c | 276 --- winsup/testsuite/winsup.api/ltp/stat03.c | 391 ---- winsup/testsuite/winsup.api/ltp/stat05.c | 241 --- winsup/testsuite/winsup.api/ltp/stat06.c | 377 ---- winsup/testsuite/winsup.api/ltp/symlink01.c | 2032 -------------------- winsup/testsuite/winsup.api/ltp/symlink02.c | 245 --- winsup/testsuite/winsup.api/ltp/symlink03.c | 404 ---- winsup/testsuite/winsup.api/ltp/symlink04.c | 238 --- winsup/testsuite/winsup.api/ltp/symlink05.c | 222 --- winsup/testsuite/winsup.api/ltp/sync01.c | 216 --- winsup/testsuite/winsup.api/ltp/sync02.c | 238 --- winsup/testsuite/winsup.api/ltp/time01.c | 218 --- winsup/testsuite/winsup.api/ltp/time02.c | 182 -- winsup/testsuite/winsup.api/ltp/times01.c | 222 --- winsup/testsuite/winsup.api/ltp/times02.c | 136 -- winsup/testsuite/winsup.api/ltp/times03.c | 247 --- winsup/testsuite/winsup.api/ltp/truncate01.c | 262 --- winsup/testsuite/winsup.api/ltp/truncate02.c | 335 ---- winsup/testsuite/winsup.api/ltp/ulimit01.c | 273 --- winsup/testsuite/winsup.api/ltp/umask01.c | 220 --- winsup/testsuite/winsup.api/ltp/umask02.c | 135 -- winsup/testsuite/winsup.api/ltp/umask03.c | 170 -- winsup/testsuite/winsup.api/ltp/uname01.c | 221 --- winsup/testsuite/winsup.api/ltp/unlink05.c | 246 --- winsup/testsuite/winsup.api/ltp/unlink06.c | 254 --- winsup/testsuite/winsup.api/ltp/unlink07.c | 328 ---- winsup/testsuite/winsup.api/ltp/unlink08.c | 432 ----- winsup/testsuite/winsup.api/ltp/vfork01.c | 400 ---- winsup/testsuite/winsup.api/ltp/wait02.c | 230 --- winsup/testsuite/winsup.api/ltp/wait401.c | 188 -- winsup/testsuite/winsup.api/ltp/wait402.c | 203 -- winsup/testsuite/winsup.api/ltp/write01.c | 250 --- winsup/testsuite/winsup.api/ltp/write02.c | 165 -- winsup/testsuite/winsup.api/ltp/write03.c | 192 -- winsup/testsuite/winsup.api/mmaptest01.c | 173 -- winsup/testsuite/winsup.api/mmaptest02.c | 190 -- winsup/testsuite/winsup.api/mmaptest03.c | 128 -- winsup/testsuite/winsup.api/mmaptest04.c | 103 - winsup/testsuite/winsup.api/msgtest.c | 348 ---- winsup/testsuite/winsup.api/nullgetcwd.c | 17 - winsup/testsuite/winsup.api/pthread/cancel1.c | 147 -- winsup/testsuite/winsup.api/pthread/cancel10.c | 68 - winsup/testsuite/winsup.api/pthread/cancel11.c | 74 - winsup/testsuite/winsup.api/pthread/cancel12.c | 69 - winsup/testsuite/winsup.api/pthread/cancel2.c | 181 -- winsup/testsuite/winsup.api/pthread/cancel3.c | 166 -- winsup/testsuite/winsup.api/pthread/cancel4.c | 172 -- winsup/testsuite/winsup.api/pthread/cancel5.c | 165 -- winsup/testsuite/winsup.api/pthread/cancel6.c | 62 - winsup/testsuite/winsup.api/pthread/cancel7.c | 71 - winsup/testsuite/winsup.api/pthread/cancel8.c | 71 - winsup/testsuite/winsup.api/pthread/cancel9.c | 81 - winsup/testsuite/winsup.api/pthread/cleanup2.c | 157 -- winsup/testsuite/winsup.api/pthread/cleanup3.c | 160 -- winsup/testsuite/winsup.api/pthread/condvar1.c | 65 - winsup/testsuite/winsup.api/pthread/condvar2.c | 80 - winsup/testsuite/winsup.api/pthread/condvar2_1.c | 107 -- winsup/testsuite/winsup.api/pthread/condvar3.c | 115 -- winsup/testsuite/winsup.api/pthread/condvar3_1.c | 145 -- winsup/testsuite/winsup.api/pthread/condvar3_2.c | 139 -- winsup/testsuite/winsup.api/pthread/condvar3_3.c | 100 - winsup/testsuite/winsup.api/pthread/condvar4.c | 137 -- winsup/testsuite/winsup.api/pthread/condvar5.c | 136 -- winsup/testsuite/winsup.api/pthread/condvar6.c | 209 -- winsup/testsuite/winsup.api/pthread/condvar7.c | 227 --- winsup/testsuite/winsup.api/pthread/condvar8.c | 221 --- winsup/testsuite/winsup.api/pthread/condvar9.c | 239 --- winsup/testsuite/winsup.api/pthread/count1.c | 62 - winsup/testsuite/winsup.api/pthread/create1.c | 34 - winsup/testsuite/winsup.api/pthread/create2.c | 74 - winsup/testsuite/winsup.api/pthread/equal1.c | 34 - winsup/testsuite/winsup.api/pthread/exit1.c | 18 - winsup/testsuite/winsup.api/pthread/exit2.c | 30 - winsup/testsuite/winsup.api/pthread/exit3.c | 34 - winsup/testsuite/winsup.api/pthread/inherit1.c | 99 - winsup/testsuite/winsup.api/pthread/join0.c | 40 - winsup/testsuite/winsup.api/pthread/join1.c | 51 - winsup/testsuite/winsup.api/pthread/join2.c | 41 - .../testsuite/winsup.api/pthread/mainthreadexits.c | 48 - winsup/testsuite/winsup.api/pthread/mutex1.c | 36 - winsup/testsuite/winsup.api/pthread/mutex1d.c | 42 - winsup/testsuite/winsup.api/pthread/mutex1e.c | 42 - winsup/testsuite/winsup.api/pthread/mutex1n.c | 42 - winsup/testsuite/winsup.api/pthread/mutex1r.c | 42 - winsup/testsuite/winsup.api/pthread/mutex2.c | 34 - winsup/testsuite/winsup.api/pthread/mutex3.c | 43 - winsup/testsuite/winsup.api/pthread/mutex4.c | 67 - winsup/testsuite/winsup.api/pthread/mutex5.c | 30 - winsup/testsuite/winsup.api/pthread/mutex6d.c | 64 - winsup/testsuite/winsup.api/pthread/mutex6e.c | 70 - winsup/testsuite/winsup.api/pthread/mutex6n.c | 72 - winsup/testsuite/winsup.api/pthread/mutex6r.c | 68 - winsup/testsuite/winsup.api/pthread/mutex7.c | 50 - winsup/testsuite/winsup.api/pthread/mutex7d.c | 51 - winsup/testsuite/winsup.api/pthread/mutex7e.c | 70 - winsup/testsuite/winsup.api/pthread/mutex7n.c | 61 - winsup/testsuite/winsup.api/pthread/mutex7r.c | 68 - winsup/testsuite/winsup.api/pthread/once1.c | 45 - winsup/testsuite/winsup.api/pthread/priority1.c | 78 - winsup/testsuite/winsup.api/pthread/priority2.c | 80 - winsup/testsuite/winsup.api/pthread/rwlock1.c | 29 - winsup/testsuite/winsup.api/pthread/rwlock2.c | 34 - winsup/testsuite/winsup.api/pthread/rwlock3.c | 45 - winsup/testsuite/winsup.api/pthread/rwlock4.c | 44 - winsup/testsuite/winsup.api/pthread/rwlock5.c | 47 - winsup/testsuite/winsup.api/pthread/rwlock6.c | 69 - winsup/testsuite/winsup.api/pthread/rwlock7.c | 189 -- winsup/testsuite/winsup.api/pthread/self1.c | 26 - winsup/testsuite/winsup.api/pthread/self2.c | 46 - winsup/testsuite/winsup.api/pthread/test.h | 102 - .../winsup.api/pthread/threadidafterfork.c | 50 - winsup/testsuite/winsup.api/pthread/tsd1.c | 170 -- winsup/testsuite/winsup.api/samples/sample-fail.c | 5 - .../winsup.api/samples/sample-miscompile.c | 1 - winsup/testsuite/winsup.api/samples/sample-pass.c | 5 - winsup/testsuite/winsup.api/semtest.c | 348 ---- winsup/testsuite/winsup.api/shmtest.c | 293 --- winsup/testsuite/winsup.api/sigchld.c | 22 - .../testsuite/winsup.api/signal-into-win32-api.c | 58 - winsup/testsuite/winsup.api/systemcall.c | 68 - winsup/testsuite/winsup.api/waitpid.c | 24 - winsup/testsuite/winsup.api/winsup.exp | 81 - 280 files changed, 58150 deletions(-) delete mode 100644 winsup/testsuite/winsup.api/checksignal.c delete mode 100644 winsup/testsuite/winsup.api/crlf.c delete mode 100644 winsup/testsuite/winsup.api/devzero.c delete mode 100644 winsup/testsuite/winsup.api/iospeed.c delete mode 100644 winsup/testsuite/winsup.api/known_bugs.tcl delete mode 100644 winsup/testsuite/winsup.api/ltp/access01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/access03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/access04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/access05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/alarm01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/alarm02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/alarm03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/alarm07.c delete mode 100644 winsup/testsuite/winsup.api/ltp/asyncio02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/chdir02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/chdir04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/chmod01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/chmod02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/chown01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/close01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/close02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/close08.c delete mode 100644 winsup/testsuite/winsup.api/ltp/creat01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/creat03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/creat09.c delete mode 100644 winsup/testsuite/winsup.api/ltp/dup01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/dup02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/dup03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/dup04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/dup05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/execl01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/execle01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/execlp01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/execv01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/execve01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/execvp01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/exit01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/exit02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fchdir01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fchdir02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fchmod01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fchown01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fcntl02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fcntl03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fcntl04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fcntl05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fcntl07.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fcntl07B.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fcntl08.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fcntl09.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fcntl10.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fork01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fork02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fork03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fork04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fork06.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fork07.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fork09.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fork10.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fork11.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fpathconf01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fstat01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fstat02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fstat03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fstat04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/fsync01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/ftruncate01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/ftruncate02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/ftruncate03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getegid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/geteuid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getgid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getgid02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getgid03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getgroups01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getgroups02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/gethostid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/gethostname01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getpgid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getpgid02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getpgrp01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getpid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getpid02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getppid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getppid02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getuid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getuid02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/getuid03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/kill01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/kill02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/kill03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/kill04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/kill09.c delete mode 100644 winsup/testsuite/winsup.api/ltp/link02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/link03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/link04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/link05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lseek01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lseek02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lseek03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lseek04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lseek05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lseek06.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lseek07.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lseek08.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lseek09.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lseek10.c delete mode 100644 winsup/testsuite/winsup.api/ltp/lstat02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mkdir01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mkdir08.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mknod01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mmap001.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mmap02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mmap03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mmap04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mmap05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mmap06.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mmap07.c delete mode 100644 winsup/testsuite/winsup.api/ltp/mmap08.c delete mode 100644 winsup/testsuite/winsup.api/ltp/munmap01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/munmap02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/nice05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/open02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/open03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/pathconf01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/pause01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/pipe01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/pipe08.c delete mode 100644 winsup/testsuite/winsup.api/ltp/pipe09.c delete mode 100644 winsup/testsuite/winsup.api/ltp/pipe10.c delete mode 100644 winsup/testsuite/winsup.api/ltp/pipe11.c delete mode 100644 winsup/testsuite/winsup.api/ltp/poll01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/read01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/read04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/readdir01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/readlink01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/readlink02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/readlink03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/rename01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/rename02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/rename08.c delete mode 100644 winsup/testsuite/winsup.api/ltp/rename10.c delete mode 100644 winsup/testsuite/winsup.api/ltp/rmdir01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/rmdir04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/rmdir05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/sbrk01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/select01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/select02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/select03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/setgid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/setgroups01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/setpgid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/setregid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/setreuid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/setuid01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/setuid02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/signal03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/stat01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/stat02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/stat03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/stat05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/stat06.c delete mode 100644 winsup/testsuite/winsup.api/ltp/symlink01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/symlink02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/symlink03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/symlink04.c delete mode 100644 winsup/testsuite/winsup.api/ltp/symlink05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/sync01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/sync02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/time01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/time02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/times01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/times02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/times03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/truncate01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/truncate02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/ulimit01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/umask01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/umask02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/umask03.c delete mode 100644 winsup/testsuite/winsup.api/ltp/uname01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/unlink05.c delete mode 100644 winsup/testsuite/winsup.api/ltp/unlink06.c delete mode 100644 winsup/testsuite/winsup.api/ltp/unlink07.c delete mode 100644 winsup/testsuite/winsup.api/ltp/unlink08.c delete mode 100644 winsup/testsuite/winsup.api/ltp/vfork01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/wait02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/wait401.c delete mode 100644 winsup/testsuite/winsup.api/ltp/wait402.c delete mode 100644 winsup/testsuite/winsup.api/ltp/write01.c delete mode 100644 winsup/testsuite/winsup.api/ltp/write02.c delete mode 100644 winsup/testsuite/winsup.api/ltp/write03.c delete mode 100644 winsup/testsuite/winsup.api/mmaptest01.c delete mode 100644 winsup/testsuite/winsup.api/mmaptest02.c delete mode 100644 winsup/testsuite/winsup.api/mmaptest03.c delete mode 100644 winsup/testsuite/winsup.api/mmaptest04.c delete mode 100644 winsup/testsuite/winsup.api/msgtest.c delete mode 100644 winsup/testsuite/winsup.api/nullgetcwd.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel10.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel11.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel12.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel3.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel4.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel5.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel6.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel7.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel8.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cancel9.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cleanup2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/cleanup3.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar2_1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar3.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar3_1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar3_2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar3_3.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar4.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar5.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar6.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar7.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar8.c delete mode 100644 winsup/testsuite/winsup.api/pthread/condvar9.c delete mode 100644 winsup/testsuite/winsup.api/pthread/count1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/create1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/create2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/equal1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/exit1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/exit2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/exit3.c delete mode 100644 winsup/testsuite/winsup.api/pthread/inherit1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/join0.c delete mode 100644 winsup/testsuite/winsup.api/pthread/join1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/join2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mainthreadexits.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex1d.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex1e.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex1n.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex1r.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex3.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex4.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex5.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex6d.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex6e.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex6n.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex6r.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex7.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex7d.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex7e.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex7n.c delete mode 100644 winsup/testsuite/winsup.api/pthread/mutex7r.c delete mode 100644 winsup/testsuite/winsup.api/pthread/once1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/priority1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/priority2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/rwlock1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/rwlock2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/rwlock3.c delete mode 100644 winsup/testsuite/winsup.api/pthread/rwlock4.c delete mode 100644 winsup/testsuite/winsup.api/pthread/rwlock5.c delete mode 100644 winsup/testsuite/winsup.api/pthread/rwlock6.c delete mode 100644 winsup/testsuite/winsup.api/pthread/rwlock7.c delete mode 100644 winsup/testsuite/winsup.api/pthread/self1.c delete mode 100644 winsup/testsuite/winsup.api/pthread/self2.c delete mode 100644 winsup/testsuite/winsup.api/pthread/test.h delete mode 100644 winsup/testsuite/winsup.api/pthread/threadidafterfork.c delete mode 100644 winsup/testsuite/winsup.api/pthread/tsd1.c delete mode 100644 winsup/testsuite/winsup.api/samples/sample-fail.c delete mode 100644 winsup/testsuite/winsup.api/samples/sample-miscompile.c delete mode 100644 winsup/testsuite/winsup.api/samples/sample-pass.c delete mode 100644 winsup/testsuite/winsup.api/semtest.c delete mode 100644 winsup/testsuite/winsup.api/shmtest.c delete mode 100644 winsup/testsuite/winsup.api/sigchld.c delete mode 100755 winsup/testsuite/winsup.api/signal-into-win32-api.c delete mode 100644 winsup/testsuite/winsup.api/systemcall.c delete mode 100644 winsup/testsuite/winsup.api/waitpid.c delete mode 100644 winsup/testsuite/winsup.api/winsup.exp (limited to 'winsup/testsuite/winsup.api') diff --git a/winsup/testsuite/winsup.api/checksignal.c b/winsup/testsuite/winsup.api/checksignal.c deleted file mode 100644 index edf720c87..000000000 --- a/winsup/testsuite/winsup.api/checksignal.c +++ /dev/null @@ -1,76 +0,0 @@ -#include -#include - -#include "test.h" -#include "usctest.h" - -const char *TCID = "checksignal"; /* Test program identifier. */ -int TST_TOTAL = 3; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -void -sig_handler (int signo) -{ - errno = EINVAL; -} - -int -main () -{ - int n, ret; - int fds[2]; - char buf[10]; - struct sigaction act; - - Tst_count = 0; - - if (pipe (fds) < 0) - tst_brk (TBROK, NULL, NULL, "Create pipe"); - - /* Reset SA_RESTART flag. */ - while ((ret = sigaction (SIGALRM, NULL, &act)) == EINTR) - ; - if (ret) - tst_brk (TBROK, NULL, NULL, "Get signal action structure"); - act.sa_flags &= ~SA_RESTART; - while ((ret = sigaction (SIGALRM, &act, NULL)) == EINTR) - ; - if (ret) - tst_brk (TBROK, NULL, NULL, "Reset SA_RESTART"); - - /* Set signal handler using signal(2) call... */ - if (signal (SIGALRM, sig_handler) < 0) - tst_brk (TBROK, NULL, NULL, "Call signal() to install signal handler"); - /* ...and check if signal(2) sets SA_RESTART again. */ - while ((ret = sigaction (SIGALRM, NULL, &act)) == EINTR) - ; - if (ret) - tst_brk (TBROK, NULL, NULL, "Get signal action structure"); - tst_resm (act.sa_flags & SA_RESTART ? TPASS : TFAIL, - "signal() sets SA_RESTART"); - - /* Reset SA_RESTART flag again. */ - act.sa_handler = sig_handler; - act.sa_flags &= ~SA_RESTART; - while ((ret = sigaction (SIGALRM, &act, NULL)) == EINTR) - ; - if (ret) - tst_brk (TBROK, NULL, NULL, "Reset SA_RESTART"); - - /* Start timer to force a SIGALRM. */ - alarm (1); - - /* Call read(2) to check if the EINTR errno is correctly preserved, - even if the signal handler routine changes errno. */ - n = read(fds[0], buf, 10); - tst_resm (n < 0 && errno == EINTR ? TPASS : TFAIL, - "Set EINTR on interrupted read() call"); - - /* Check if another errno is correctly returned (here EBADF). */ - close (fds[0]); - n = read(fds[0], buf, 10); - tst_resm (n < 0 && errno == EBADF ? TPASS : TFAIL, - "Set EBADF on closed file descriptor"); - - tst_exit (); -} diff --git a/winsup/testsuite/winsup.api/crlf.c b/winsup/testsuite/winsup.api/crlf.c deleted file mode 100644 index ea79122f0..000000000 --- a/winsup/testsuite/winsup.api/crlf.c +++ /dev/null @@ -1,527 +0,0 @@ -typedef enum { - Nop=100000, /* ; do nothing */ - New1, /* ; reset and begin new test */ - Open, /* ; open test file */ - Read, /* [askfor] [get] ; read bytes into buffer */ - Write, /* [expect] [bytestream] ; write to file (expect 0 = ignore)*/ - Compare, /* [bytestream] ; compare buffer to given bytes */ - Verify, /* [bytestream] ; compare file to given bytes */ - Seek, /* [offset] [whence] ; seek in file */ - Tell, /* [offset] ; compare file positions */ - BufSize, /* [size] ; change the stdio buffer size */ - Flush, /* ; flush the stdio stream */ - Text, /* ; switch file to text mode */ - Binary, /* ; switch file to binary mode */ - Rep, /* [count] ; repeat 'R' bytes (used in bytestream) */ - Fill, /* [posn] ; fill 'F' until given byte position */ - Start, /* ; for Seek */ - Current, /* ; for Seek */ - End, /* ; for Seek, or end of byte stream */ - Max } Opcode; - -#define New New1,__LINE__ - -/* Byte streams are just inserted into the command stream, and must - end in an End code. */ - -int commands[] = { -#ifndef __DJGPP__ - New, - Write, 1605, Rep, 1600, 'h', 'e', 'l', 'l', 'o', End, - Tell, 1605, - - Open, - BufSize, 16, - Read, 1605, 1605, - Compare, Rep, 1600, 'h', 'e', 'l', 'l', 'o', End, - Tell, 1605, - Flush, - Tell, 1605, - Seek, 1000, Start, - Tell, 1000, - - New, - Text, - Write, 2, 'x', 10, End, - Verify, 'x', 13, 10, End, - - New, - Binary, - Write, 2, 'x', 10, End, - Verify, 'x', 10, End, - - BufSize, 16, - - New, - Binary, - Write, 0, Fill, 15, 13, 10, 'x', End, - Text, Open, - Read, 17, 17, - Compare, Fill, 15, 10, 'x', End, - Tell, 18, - - New, - Binary, - Write, 0, Fill, 14, 13, 10, 'x', End, - Text, Open, - Read, 16, 16, - Compare, Fill, 14, 10, 'x', End, - Tell, 17, - - New, - Binary, - Write, 0, 13, 10, 'a', 'b', End, - Text, Open, - Read, 2, 2, - Compare, 10, 'a', End, - Tell, 3, - - New, - Binary, - Write, 0, 10, 'a', 'b', End, - Text, Open, - Read, 2, 2, - Compare, 10, 'a', End, - Tell, 2, - - New, - Binary, - Write, 0, 13, 'a', 'b', End, - Text, Open, - Read, 2, 2, - Compare, 13, 'a', End, - Tell, 2, - - New, - Binary, - Write, 0, 13, 13, 10, 'a', End, - Text, Open, - Read, 2, 2, - Compare, 13, 10, End, - Tell, 3, - - New, - Binary, - Write, 0, 13, 10, 'a', 13, End, - Text, Open, - Read, 2, 2, - Compare, 10, 'a', End, - Tell, 3, - - New, - Binary, - Write, 0, 13, 10, 'a', 10, End, - Text, Open, - Read, 2, 2, - Compare, 10, 'a', End, - Tell, 3, - - New, - Binary, - Write, 0, 13, 13, 13, 10, 'a', 10, 10, 10, End, - Text, Open, - Read, 4, 4, - Compare, 13, 13, 10, 'a', End, - Tell, 5, -#endif - - New, - Binary, - Write, 0, 13, 13, 13, 10, 'a', 'b', 13, 10, 13, 10, End, - Text, Open, - Read, 4, 4, - Compare, 13, 13, 10, 'a', End, - Tell, 5, - - }; - -/*==========================================================================*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef O_BINARY -#define O_BINARY 0 -#endif -#ifndef O_TEXT -#define O_TEXT 0 -#endif - -int errors = 0; - -#define num_commands (int)(sizeof(commands)/sizeof(commands[0])) - -int pc; -int askfor, get, expect, count, posn, whence, size; - -typedef struct { - unsigned char *bytes; - int max, count; -} Buffer; - -Buffer rw_buf={0,0,0}, cmp_buf={0,0,0}, vfy_buf={0,0,0}; - -void -expand_buf(Buffer *buf, int len) -{ - if (buf->max < len) - { - buf->max = len+20; - if (buf->bytes) - buf->bytes = (unsigned char *)realloc(buf->bytes, buf->max); - else - buf->bytes = (unsigned char *)malloc(buf->max); - } -} - -void -get_bytestream(Buffer *buf) -{ - int tpc; - int len = 0, rep, byte; - unsigned char *bp; - - for (tpc = pc+1; tpc < num_commands && commands[tpc] != End; tpc++) - { - switch (commands[tpc]) - { - case Rep: - len += commands[tpc+1]; - tpc ++; - break; - case Fill: - if (len < commands[tpc+1]) - len = commands[tpc+1]; - tpc ++; - break; - default: - len ++; - break; - } - } - - expand_buf(buf, len); - - len = 0; - bp = buf->bytes; - - for (tpc = pc+1; tpc < num_commands && commands[tpc] != End; tpc++) - { - switch (commands[tpc]) - { - case Rep: - rep = commands[++tpc]; - byte = 'R'; - while (rep--) *bp++ = byte; - break; - case Fill: - rep = commands[++tpc]; - byte = 'F'; - while (bp-buf->bytes < rep) *bp++ = byte; - break; - default: - *bp++ = commands[tpc]; - break; - } - } - buf->count = bp - buf->bytes; - pc = tpc; -} - -char dataname[] = "crlf.dat"; - -int verbose=0; -void -v(char *fmt, ...) -{ - va_list ap; - if (!verbose) return; - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - va_end(ap); - printf("\n"); -} - -void -vp(const char *fmt, ...) -{ - va_list ap; - if (!verbose) return; - printf("%08x: ", pc); - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - va_end(ap); - printf("\n"); -} - -void -errorq(int use_errno, const char *fmt, ...) -{ - va_list ap; - fprintf(stderr, "crlf: Error at pc=%d: ", pc); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, "\n"); - if (use_errno) - perror("The error was"); - errors++; -} - -void -error(int use_errno, const char *fmt, ...) -{ - va_list ap; - fprintf(stderr, "crlf: Error at pc=%d: ", pc); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, "\n"); - if (use_errno) - perror("The error was"); - fprintf(stderr, "FAIL\n"); - exit(1); -} - -void -display_buf(const char *which, Buffer *buf, int ofs) -{ - int i; - fprintf(stderr, "%s %04x:", which, ofs); - for (i=0; i<8; i++) - if (i+ofs < buf->count) - { - unsigned char b = buf->bytes[i+ofs]; - fprintf(stderr, " %02x", b); - if (isgraph(b)) - fprintf(stderr, " %c ", b); - else - fprintf(stderr, " . "/*, b*/); - } - fprintf(stderr, "\n"); -} - -void -compare_bufs(const char *name, Buffer *actual, Buffer *expected) -{ - int i, got_one=0; - for (i=0; icount && icount; i++) - if (actual->bytes[i] != expected->bytes[i]) - { - errorq(0, "%s: byte mismatch at offset 0x%x", name, i); - got_one = 1; - break; - } - if (!got_one) - { - if (actual->count < expected->count) - errorq(0, "%s: too few bytes (0x%x vs 0x%x)", name, - actual->count, expected->count); - else if (actual->count > expected->count) - errorq(0, "%s: too many bytes (0x%x vs 0x%x)", name, - actual->count, expected->count); - else - return; - } - - i -= 4; - if (i<0) i = 0; - display_buf("Actual ", actual, i); - display_buf("Expected", expected, i); -} - -int -main(int argc, char **argv) -{ - const char *readmode = "rb"; - const char *writemode = "wb"; - FILE *file = 0; - int i; - struct stat st; - const char *str = ""; - - while (argc > 1 && argv[1][0] == '-') - { - if (strcmp(argv[1], "-v") == 0) - verbose++; - argc--; - argv++; - } - - size = 0; - - for (pc=0; pc -#include -#include -#include -#include -#include - -int -main(int argc, char **argv) -{ - int fd, r, l; - char buf[1024]; - char *v; - - fd = open("/dev/zero", O_RDONLY); - if (fd < 0) - { - fprintf(stderr, "Unable to open /dev/zero for reading\n"); - perror("The error was"); - exit(1); - } - - l = read(fd, buf, 1024); - if (l != 1024) - { - fprintf(stderr, "Asked to read 1024 bytes, got %d\n", l); - exit(1); - } - - for (r=0; r<1024; r++) - if (buf[r] != 0) - { - fprintf(stderr, "/dev/zero returned a byte of %02x at offset %d\n", - buf[r], r); - exit(1); - } - - l = lseek(fd, 4096, 0); - if (l != 0) - { - fprintf(stderr, "l == %d\n", l); - exit(1); - } - - l = close(fd); - if (l != 0) - { - fprintf(stderr, "close: returned %d\n", l); - perror("The error was"); - exit(1); - } - - fd = open("/dev/zero", O_WRONLY); - if (fd < 0) - { - fprintf(stderr, "Unable to open /dev/zero for writing\n"); - perror("The error was"); - exit(1); - } - - l = write(fd, buf, 1024); - if (l != 1024) - { - fprintf(stderr, "Asked to write 1024 bytes, got %d\n", l); - exit(1); - } - - l = close(fd); - if (l != 0) - { - fprintf(stderr, "close: returned %d\n", l); - perror("The error was"); - exit(1); - } - - fd = open("/dev/zero", O_RDWR); - v = (char *)mmap(0, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); - if (v == (char *)-1) - { - fprintf(stderr, "mmap r/w /dev/zero failed\n"); - perror("The error was"); - exit(1); - } - - for (r=0; r<65536; r++) - if (v[r] != 0) - { - fprintf(stderr, "mmap'd r/w /dev/zero has byte %d at offset %d\n", - v[r], r); - exit(1); - } - munmap(v, 65536); - close(fd); - - fd = open("/dev/zero", O_RDONLY); - v = (char *)mmap(0, 65536, PROT_READ, MAP_SHARED, fd, 0); - if (v == (char *)-1) - { - fprintf(stderr, "mmap /dev/zero r/o failed\n"); - perror("The error was"); - exit(1); - } - - for (r=0; r<65536; r++) - if (v[r] != 0) - { - fprintf(stderr, "mmap'd r/o /dev/zero has byte %d at offset %d\n", - v[r], r); - exit(1); - } - munmap(v, 65536); - close(fd); - - exit(0); -} diff --git a/winsup/testsuite/winsup.api/iospeed.c b/winsup/testsuite/winsup.api/iospeed.c deleted file mode 100644 index 56bf715cf..000000000 --- a/winsup/testsuite/winsup.api/iospeed.c +++ /dev/null @@ -1,115 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -int verbose = 0; - -void -v(char *fmt, ...) -{ - va_list ap; - if (!verbose) return; - va_start(ap, fmt); - vfprintf(stdout, fmt, ap); - va_end(ap); -} - -#define TSIZE (1024 * 1024 * 16) - -unsigned long start_tic; - -void -start(FILE *f) -{ - fseek(f, 0, SEEK_SET); - start_tic = GetTickCount(); -} - -void -end() -{ - unsigned long end_tic = GetTickCount(); - printf("%6ld", end_tic - start_tic); -} - -void -test(int linesz, int cr) -{ - FILE *f = fopen("iospeed.dat", "wb"); - char buf[65536]; - int i, fd; - - memset(buf, 'x', linesz); - buf[linesz-1] = '\n'; - if (cr) - buf[linesz-2] = '\r'; - for (i=0; i 0); - end(); - - start(f); - while (fgets(buf, 64436, f)); - end(); - - f = fopen("iospeed.dat", "rb"); - fd = fileno(f); - - for (i=0; i 0); - end(); - - start(f); - while (fgets(buf, 64436, f)); - end(); - - printf("\n"); -} - -int -main(int argc, char **argv) -{ - if (argc > 1 && strcmp(argv[1],"-v") == 0) - verbose = 1; - - setbuf(stdout, 0); - - printf(" ----- text ----- ---- binary ----\n"); - printf("linesz cr getc fread fgets getc fread fgets\n"); - - test(4, 0); - test(64, 0); - test(4096, 0); - test(4, 1); - test(64, 1); - test(4096, 1); - - remove ("iospeed.dat"); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/known_bugs.tcl b/winsup/testsuite/winsup.api/known_bugs.tcl deleted file mode 100644 index f3fc01527..000000000 --- a/winsup/testsuite/winsup.api/known_bugs.tcl +++ /dev/null @@ -1,8 +0,0 @@ -set xfail_list [list dup03 dup05 \ - fcntl05 fcntl07B \ - lseek04 mknod01 select03 \ - setgroups01 setuid02 \ - ulimit01 unlink06 unlink08 \ - sample-fail sample-miscompile] - - diff --git a/winsup/testsuite/winsup.api/ltp/access01.c b/winsup/testsuite/winsup.api/ltp/access01.c deleted file mode 100644 index ae9be948a..000000000 --- a/winsup/testsuite/winsup.api/ltp/access01.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" -void setup(); -void cleanup(void) __attribute__((noreturn)); - -const 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]; - - -/*********************************************************************** - * Main - ***********************************************************************/ -int main(int ac, char **av) -{ - struct test_case_t { - char *file; - unsigned mode; - const 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); - int lc; /* loop counter */ - const 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 -#include -#include - - -#include "test.h" -#include "usctest.h" - - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - -char *get_high_address(); - -const 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 */ - const 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/access04.c b/winsup/testsuite/winsup.api/ltp/access04.c deleted file mode 100644 index 069458886..000000000 --- a/winsup/testsuite/winsup.api/ltp/access04.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: access01 - * - * Test Description: - * Verify that access() succeeds to check the existance of a file if - * search access is permitted on the pathname of the specified file. - * - * Expected Result: - * access() should return 0 value and the specified file should exist - * on the file system. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * access01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TESTDIR "testdir" -#define TESTFILE "testdir/testfile" -#define DIR_MODE S_IRWXU | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH - -const char *TCID="access01"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* struct buffer for stat(2) */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *)NULL, NULL); - if (msg != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call access(2) to check the existence of a - * file under specified path. - */ - TEST(access(TESTFILE, F_OK)); - - /* check return code of access(2) */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "access(%s, F_OK) Failed, errno=%d : %s", - TESTFILE, TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Use stat(2) to cross-check the - * existance of testfile under - * specified path. - */ - if (stat(TESTFILE, &stat_buf) < 0) { - tst_resm(TFAIL, "stat() on %s Failed, errno=%d", - TESTFILE, TEST_ERRNO); - } else { - tst_resm(TPASS, "Functionality of access(%s, " - "F_OK) successful", TESTFILE); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test. - * - * Create a temporary directory and change directory to it. - * Create a test directory and a file under test directory. - * Modify the mode permissions of testfile. - */ -void -setup() -{ - int fd; /* File handle for testfile */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Check that the test process id is not root/super-user */ - if (geteuid() == 0) { - tst_brkm(TBROK, NULL, "Must be non-root/super for this test!"); - tst_exit(); - } - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a test directory under temporary directory */ - if (mkdir(TESTDIR, DIR_MODE) < 0) { - tst_brkm(TBROK, cleanup, - "mkdir(%s, %#o) Failed, errno=%d : %s", - TESTDIR, DIR_MODE, errno, strerror(errno)); - } - - /* Make sure test directory has search permissions set */ - if (chmod(TESTDIR, DIR_MODE) < 0) { - tst_brkm(TBROK, cleanup, - "chmod(%s, %#o) Failed, errno=%d : %s", - TESTDIR, DIR_MODE, errno, strerror(errno)); - } - - /* Creat a test file under above directory created */ - if ((fd = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - } - - /* Close the testfile created above */ - if (close(fd) == -1) { - tst_brkm(TBROK, cleanup, - "close(%s) Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } - - /* Change the mode permissions on the testfile */ - if (chmod(TESTFILE, 0) < 0) { - tst_brkm(TBROK, cleanup, - "chmod(%s, 0) Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } -} - - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* - * Delete the test directory/file and temporary directory - * created in the setup. - */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/access05.c b/winsup/testsuite/winsup.api/ltp/access05.c deleted file mode 100644 index 757c64f33..000000000 --- a/winsup/testsuite/winsup.api/ltp/access05.c +++ /dev/null @@ -1,424 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: access03 - * - * Test Description: - * Verify that, - * 1. access() fails with -1 return value and sets errno to EACCES - * if the permission bits of the file mode do not permit the - * requested (Read/Write/Execute) access. - * 2. access() fails with -1 return value and sets errno to EINVAL - * if the specified access mode argument is invalid. - * 3. access() fails with -1 return value and sets errno to EFAULT - * if the pathname points outside allocate address space for the - * process. - * 4. access() fails with -1 return value and sets errno to ENOENT - * if the specified file doesn't exist (or pathname is NULL). - * 5. access() fails with -1 return value and sets errno to ENAMETOOLONG - * if the pathname size is > PATH_MAX characters. - * - * Expected Result: - * access() should fail with return value -1 and set expected errno. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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) - * if errno set == expected errno - * Issue sys call fails with expected return value and errno. - * Otherwise, - * Issue sys call fails with unexpected errno. - * Otherwise, - * Issue sys call returns unexpected value. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory(s)/file(s) created. - * - * Usage: - * access03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * This test should be run by 'non-super-user' only. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define INV_OK -1 -#define TEST_FILE1 "test_file1" -#define TEST_FILE2 "test_file2" -#define TEST_FILE3 "test_file3" -#define TEST_FILE4 "test_file4" - -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH - -int no_setup(); -int setup1(); /* setup() to test access() for EACCES */ -int setup2(); /* setup() to test access() for EACCES */ -int setup3(); /* setup() to test access() for EACCES */ -int setup4(); /* setup() to test access() for EINVAL */ -int longpath_setup(); /* setup function to test access() for ENAMETOOLONG */ - -char Longpathname[PATH_MAX+2]; -char High_address_node[64]; - -struct test_case_t { /* test case structure */ - const char *pathname; - int a_mode; - const char *desc; - int exp_errno; - int (*setupfunc)(); -} Test_cases[] = { - { TEST_FILE1, R_OK, "Read Access denied on file", EACCES, setup1 }, - { TEST_FILE2, W_OK, "Write Access denied on file", EACCES, setup2 }, - { TEST_FILE3, X_OK, "Execute Access denied on file", EACCES, setup3 }, - { TEST_FILE4, INV_OK, "Access mode invalid", EINVAL, setup4 }, - { High_address_node, R_OK, "Address beyond address space", EFAULT, no_setup }, - { (char *)-1, R_OK, "Negative address", EFAULT, no_setup }, - { "", W_OK, "Pathname is empty", ENOENT, no_setup }, - { Longpathname, R_OK, "Pathname too long", ENAMETOOLONG, longpath_setup }, - { NULL, 0, NULL, 0, no_setup } -}; - -const 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[]={EACCES, EFAULT, EINVAL, ENOENT, ENAMETOOLONG, 0}; - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ -char *get_high_address (void); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - const char *file_name; /* name of the testfile */ - const char *test_desc; /* test specific message */ - int access_mode; /* specified access mode for testfile */ - int ind; /* counter for testcase looping */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* Perform global setup for test */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Check looping state if -i 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++) { - file_name = Test_cases[ind].pathname; - access_mode = Test_cases[ind].a_mode; - test_desc = Test_cases[ind].desc; - - if (file_name == High_address_node) { - file_name = (char *)get_high_address(); - } - - /* - * Call access(2) to test different test conditions. - * verify that it fails with -1 return value and - * sets appropriate errno. - */ - TEST(access(file_name, access_mode)); - - if (TEST_RETURN != -1) { - tst_resm(TFAIL, "access() returned %d, " - "expected -1, errno:%d", TEST_RETURN, - Test_cases[ind].exp_errno); - continue; - } - - TEST_ERROR_LOG(TEST_ERRNO); - - /* - * Call a function to verify whether - * the specified file has specified - * access mode. - */ - if (TEST_ERRNO == Test_cases[ind].exp_errno) { - tst_resm(TPASS, "access() fails, %s, errno:%d", - test_desc, TEST_ERRNO); - } else { - tst_resm(TFAIL, "access() fails, %s, errno:%d, " - "expected errno:%d", test_desc, - TEST_ERRNO, Test_cases[ind].exp_errno); - } - } /* Test Case Looping */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test. - * - * Create a temporary directory and change directory to it. - * Call individual test specific setup functions. - */ -void -setup() -{ - int ind; /* counter for testsetup functions */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Check that the test process id is not root/super-user */ - if (geteuid() == 0) { - tst_brkm(TBROK, NULL, "Must be non-root/super for this test!"); - tst_exit(); - } - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* call individual setup functions */ - for (ind = 0; Test_cases[ind].desc != NULL; ind++) { - Test_cases[ind].setupfunc(); - } -} - -/* - * no_setup() - some test conditions do not need any setup. - * Hence, this function simply returns 0. - */ -int -no_setup() -{ - return 0; -} - -/* - * setup1() - Setup function to test access() for return value -1 - * and errno EACCES when read access denied for specified - * testfile. - * - * Creat/open a testfile and close it. - * Deny read access permissions on testfile. - * This function returns 0. - */ -int -setup1() -{ - int fd1; /* file handle for testfile */ - - /* Creat a test file under above directory created */ - if ((fd1 = open(TEST_FILE1, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s", - TEST_FILE1, FILE_MODE, errno, strerror(errno)); - } - - /* Close the testfile created above */ - if (close(fd1) == -1) { - tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s", - TEST_FILE1, errno, strerror(errno)); - } - - /* Change mode permissions on testfile */ - if (chmod(TEST_FILE1, 0333) < 0) { - tst_brkm(TBROK, cleanup, "chmod() failed on %s, errno=%d", - TEST_FILE1, errno); - } - - return 0; -} - -/* - * setup2() - Setup function to test access() for return value -1 and - * errno EACCES when write access denied on testfile. - * - * Creat/open a testfile and close it. - * Deny write access permissions on testfile. - * This function returns 0. - */ -int -setup2() -{ - int fd2; /* file handle for testfile */ - - /* Creat a test file under above directory created */ - if ((fd2 = open(TEST_FILE2, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s", - TEST_FILE2, FILE_MODE, errno, strerror(errno)); - } - - /* Close the testfile created above */ - if (close(fd2) == -1) { - tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s", - TEST_FILE2, errno, strerror(errno)); - } - - /* Change mode permissions on testfile */ - if (chmod(TEST_FILE2, 0555) < 0) { - tst_brkm(TBROK, cleanup, "chmod() failed on %s, errno=%d", - TEST_FILE2, errno); - } - - return 0; -} - -/* - * setup3() - Setup function to test access() for return value -1 and - * errno EACCES when execute access denied on testfile. - * - * Creat/open a testfile and close it. - * Deny search access permissions on testfile. - * This function returns 0. - */ -int -setup3() -{ - int fd3; /* file handle for testfile */ - - /* Creat a test file under above directory created */ - if ((fd3 = open(TEST_FILE3, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s", - TEST_FILE3, FILE_MODE, errno, strerror(errno)); - } - - /* Close the testfile created above */ - if (close(fd3) == -1) { - tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s", - TEST_FILE3, errno, strerror(errno)); - } - - /* Change mode permissions on testfile */ - if (chmod(TEST_FILE3, 0666) < 0) { - tst_brkm(TBROK, cleanup, "chmod() failed on %s, errno=%d", - TEST_FILE3, errno); - } - - return 0; -} - -/* - * setup4() - Setup function to test access() for return value -1 - * and errno EINVAL when specified access mode argument is - * invalid. - * - * Creat/open a testfile and close it. - * This function returns 0. - */ -int -setup4() -{ - int fd4; /* file handle for testfile */ - - /* Creat a test file under above directory created */ - if ((fd4 = open(TEST_FILE4, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s", - TEST_FILE4, FILE_MODE, errno, strerror(errno)); - } - - /* Close the testfile created above */ - if (close(fd4) == -1) { - tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s", - TEST_FILE4, errno, strerror(errno)); - } - - return 0; -} - -/* - * longpath_setup() - setup to create a node with a name length exceeding - * the MAX. length of PATH_MAX. - */ -int -longpath_setup() -{ - int ind; - - for (ind = 0; ind <= (PATH_MAX + 1); ind++) { - Longpathname[ind] = 'a'; - } - - return 0; -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* - * Delete the test directory/file and temporary directory - * created in the setup. - */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/alarm01.c b/winsup/testsuite/winsup.api/ltp/alarm01.c deleted file mode 100644 index 187e488c9..000000000 --- a/winsup/testsuite/winsup.api/ltp/alarm01.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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 -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 03a41b4f7..000000000 --- a/winsup/testsuite/winsup.api/ltp/alarm02.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "test.h" -#include "usctest.h" /* required for usctest */ - -void setup(); -void cleanup(void) __attribute__((noreturn)); -void alarm_received(); - - - -const 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 */ - const char *msg; /* message returned from parse_opts */ - - /* Parameters for alarm test */ - const 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 -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - -const 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 */ - const 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/alarm07.c b/winsup/testsuite/winsup.api/ltp/alarm07.c deleted file mode 100644 index a9f269522..000000000 --- a/winsup/testsuite/winsup.api/ltp/alarm07.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: alarm03 - * - * Test Description: - * Check the functionality of the alarm() when the time input - * parameter is non-zero and the process does a fork. - * - * Expected Result: - * The alarm request should be cleared in the child process. - * - * Algorithm: - * 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, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * - * Usage: - * alarm03 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -const 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 almreceived = 0; /* flag to indicate SIGALRM received or not */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ -void sigproc(int sig); /* signal catching function */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - int time_sec = 3; /* time for which alarm is set */ - int sleep_time = 5; /* waiting time for the SIGALRM signal */ - pid_t cpid; /* child process id */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *)NULL, NULL); - if (msg != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call First alarm() with non-zero time parameter - * 'time_sec' to send SIGALRM to the process. - */ - TEST(alarm(time_sec)); - - /* Now, fork a child process */ - cpid = fork(); - if (cpid < 0) { - tst_resm(TFAIL, "fork() fails to create child, " - "errno:%d", errno); - } - - /* Wait for signal SIGALRM to be generated */ - sleep(sleep_time); - - if (STD_FUNCTIONAL_TEST) { - if (cpid == 0) { /* Child process */ - /* - * For child process if almreceived is 0 - * means alarm request is cleared. - */ - if (almreceived == 0) { - tst_resm(TPASS, "Functionality of " - "alarm(%u) successful", - time_sec); - } else { - tst_resm(TFAIL, "alarm request not " - "cleared in child, " - "almreceived:%d", almreceived); - } - } else { /* Parent process */ - /* Wait for child to complete execution */ - wait(0); - } - } else { - tst_resm(TPASS, "call returned %d", TEST_RETURN); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Setup signal handler to catch SIGALRM signal. - */ -void -setup() -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Set the signal catching function */ - if (signal(SIGALRM, sigproc) == SIG_ERR) { - tst_brkm(TFAIL, cleanup, - "signal() fails to catch SIGALARM, errno=%d", - errno); - } -} - - -/* - * sigproc(int) - This function defines the action that has to be taken - * when the SIGALRM signal is caught. - * It also sets the variable which is used to check whether the - * alarm system call was successful. - */ -void -sigproc(int sig) -{ - almreceived = almreceived + 1; -} - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/asyncio02.c b/winsup/testsuite/winsup.api/ltp/asyncio02.c deleted file mode 100644 index 36c03b449..000000000 --- a/winsup/testsuite/winsup.api/ltp/asyncio02.c +++ /dev/null @@ -1,364 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#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(void) __attribute__((noreturn)); -int testrun(int flag, int bytes, int ti); - -const 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]; -const 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 */ - const 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= 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 deleted file mode 100644 index 552f912ac..000000000 --- a/winsup/testsuite/winsup.api/ltp/chdir02.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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 -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - -const 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}; - -const char *dirs[2] = { "/", "/tmp" }; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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/chdir04.c b/winsup/testsuite/winsup.api/ltp/chdir04.c deleted file mode 100644 index da2b0ace9..000000000 --- a/winsup/testsuite/winsup.api/ltp/chdir04.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * chdir02.c - * - * DESCRIPTION - * Testcase to test whether chdir(2) sets errno correctly. - * - * ALGORITHM - * 1. Test for ENAMETOOLONG: - * Create a bad directory name with length more than - * - * VFS_MAXNAMELEN (Linux kernel variable), and attempt to - * chdir(2) to it. - * - * 2. Test for ENOENT: - * Attempt to chdir(2) on a non-existent directory - * - * 3. Test for EFAULT: - * Pass an address which lies outside the address space of the - * process, and expect an EFAULT. - * - * USAGE: - * chdir02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * NONE - */ - -#include -#include -#include -#include - -const char *TCID = "chdir02"; -int TST_TOTAL = 3; -extern int Tst_count; - -int exp_enos[] = {ENAMETOOLONG, ENOENT, EFAULT, 0}; - -char bad_dir[] = "abcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyz"; - -char noexist_dir[] = "/tmp/noexistdir"; - -struct test_case_t { - char *dname; - int error; -} TC[] = { - /* - * to test whether chdir() is setting ENAMETOOLONG if the - * directory is more than VFS_MAXNAMELEN - */ - {bad_dir, ENAMETOOLONG}, - - /* - * to test whether chdir() is setting ENOENT if the - * directory is not existing. - */ - {noexist_dir, ENOENT}, - - /* - * to test whether chdir() is setting EFAULT if the - * directory is an invalid address. - */ - {(void *)-1, EFAULT} -}; - -int flag; -#define FAILED 1 - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - int i; - const 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); - } - - setup(); - - /* set up the expected errnos */ - TEST_EXP_ENOS(exp_enos); - - /* check looping state if -i option is given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - /* loop through the test cases */ - for (i=0; i - * chmod01 [-c n] [-e] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define TESTFILE "testfile" - -const char *TCID="chmod01"; /* Test program identifier. */ -int TST_TOTAL=8; /* Total number of test conditions */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -int Modes[] = {0, 07, 070, 0700, 0777, 02777, 04777, 06777}; - -void setup(); /* setup function for the test */ -void cleanup() __attribute__ ((noreturn));/* cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat(2) struct contents */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - int ind; /* counter variable for chmod(2) tests */ - unsigned mode; /* file mode permission */ - - TST_TOTAL = sizeof(Modes) / sizeof(int); - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i 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 different mode permission - * bits to set it for "testfile". - */ - TEST(chmod(TESTFILE, mode)); - - /* check return code of chmod(2) */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "chmod(%s, %#o) Failed, errno=%d : %s", - TESTFILE, mode, TEST_ERRNO, - strerror(TEST_ERRNO)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Get the testfile information using - * stat(2). - */ - if (stat(TESTFILE, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, "stat(2) of " - "%s failed, errno:%d", - TESTFILE, TEST_ERRNO); - } - stat_buf.st_mode &= ~S_IFREG; - - /* - * Check for expected mode permissions - * on testfile. - */ - if (stat_buf.st_mode == mode) { - tst_resm(TPASS, "Functionality of " - "chmod(%s, %#o) successful", - TESTFILE, mode); - } else { - tst_resm(TFAIL, "%s: Incorrect " - "modes 0%03o, Expected 0%03o", - TESTFILE, stat_buf.st_mode, - mode); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and close it - */ -void -setup() -{ - int fd; - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a test file under temporary directory and close it */ - if ((fd = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - } - if (close(fd) == -1) { - tst_brkm(TBROK, cleanup, - "close(%s) Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } - -} /* End setup() */ - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test directory and testfile created in the setup. - */ -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/chmod02.c b/winsup/testsuite/winsup.api/ltp/chmod02.c deleted file mode 100644 index 8026768ae..000000000 --- a/winsup/testsuite/winsup.api/ltp/chmod02.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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]; -const 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 */ - const 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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; -const char *buf = "davef"; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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/close01.c b/winsup/testsuite/winsup.api/ltp/close01.c deleted file mode 100644 index 4d4059823..000000000 --- a/winsup/testsuite/winsup.api/ltp/close01.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * close01.c - * - * DESCRIPTION - * Test that closing a regular file and a pipe works correctly - * - * ALGORITHM - * Creat a file, and dup() a fildes - * Open a pipe - * call close() using the TEST macro - * if the call fails - * issue a FAIL message and continue - * else if STD_FUNCTIONAL_TEST - * attempt to close the file/pipe again - * if there is an error - * issue a PASS message - * else - * issue a FAIL message - * else - * issue a PASS message - * - * - * USAGE: - * close01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID = "close01()"; -int TST_TOTAL = 2; -extern int Tst_count; - -char fname[40] = ""; - -int fild = -1; -int newfd = -1; -int pipefildes[2]; - -struct test_case_t { - int *fd; - const char *type; -} TC[] = { - /* file descriptor for a regular file */ - {&newfd, "file"}, - - /* file descriptor for a pipe */ - {&pipefildes[0], "pipe"} -}; - -int -main(int ac, char **av) -{ - - int i; - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - setup(); /* global setup */ - - /* The following loop checks looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - /* set up the file and pipe for the test */ - if ((fild = creat(fname, 0777)) == -1) { - perror (fname); - tst_brkm(TBROK, cleanup, "can't open file %s", fname); - } - - if ((newfd = dup(fild)) == -1) { - tst_brkm(TBROK, cleanup, "can't dup the file des"); - } - - if (pipe(pipefildes) == -1) { - tst_brkm(TBROK, cleanup, "can't open pipe"); - } - - /* loop through the test cases */ - - for (i = 0; i < TST_TOTAL; i++) { - - TEST(close(*TC[i].fd)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "call failed unexpectedly"); - continue; - } - - if (STD_FUNCTIONAL_TEST) { - /* attempt to close the fd again */ - if (close(*TC[i].fd) == -1) { - tst_resm(TPASS, "%s appears closed", - TC[i].type); - } else { - tst_resm(TFAIL, "%s close succeeded on" - "second attempt", TC[i].type); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } - - } - cleanup(); - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup(void) -{ - int mypid; - - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - umask(0); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - mypid = getpid(); - sprintf(fname, "fname.%d", mypid); -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup(void) -{ - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ - TEST_CLEANUP; - - if (fild >= 0) - close (fild); - if (newfd >= 0) - close (newfd); - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/close02.c b/winsup/testsuite/winsup.api/ltp/close02.c deleted file mode 100644 index 72ecf8181..000000000 --- a/winsup/testsuite/winsup.api/ltp/close02.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * close02.c - * - * DESCRIPTION - * Check that an invalid file descriptor returns EBADF - * - * ALGORITHM - * loop if that option is specified - * call close using the TEST macro and passing in an invalid fd - * if the call succeedes - * issue a FAIL message - * else - * log the errno - * if the errno == EBADF - * issue a PASS message - * else - * issue a FAIL message - * cleanup - * - * USAGE: - * close02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include "test.h" -#include "usctest.h" - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -int exp_enos[] = {EBADF, 0}; - -const char *TCID = "close02()"; -int TST_TOTAL = 1; -extern int Tst_count; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - setup(); /* global setup */ - - /* set up expected errnos */ - TEST_EXP_ENOS(exp_enos); - - /* The following loop checks looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(close(-1)); - - if (TEST_RETURN != -1) { - tst_resm(TFAIL, "Closed a non existent fildes"); - } else { - TEST_ERROR_LOG(TEST_ERRNO); - - if (TEST_ERRNO != EBADF) { - tst_resm(TFAIL, "close() FAILED to set errno " - "to EBADF on an invalid fd, got %d", - errno); - } else { - tst_resm(TPASS, "call returned EBADF"); - } - } - } - cleanup(); - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - umask(0); - - /* Pause if that option was specified */ - TEST_PAUSE; -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup(void) -{ - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ - TEST_CLEANUP; - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/close08.c b/winsup/testsuite/winsup.api/ltp/close08.c deleted file mode 100644 index 3fbcc3be8..000000000 --- a/winsup/testsuite/winsup.api/ltp/close08.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/creat01.c b/winsup/testsuite/winsup.api/ltp/creat01.c deleted file mode 100644 index 6f891701e..000000000 --- a/winsup/testsuite/winsup.api/ltp/creat01.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * creat01.c - * - * DESCRIPTION - * Testcase to check the basic functionality of the creat(2) system call. - * - * ALGORITHM - * 1. creat() a file using 0444 mode, write to the fildes, write - * should return a positive count. - * - * 2. creat() should truncate a file to 0 bytes if it already - * exists, and should not fail. - * - * USAGE: - * creat01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(void); -void cleanup(void) __attribute__((noreturn)); -void functest1(void); -void functest2(void); - -const char *TCID = "creat01"; -int TST_TOTAL = 2; -extern int Tst_count; - -char filename[40]; - -#define MODE1 0644 -#define MODE2 0444 - -struct test_case_t { - char *fname; - int mode; - void (*functest)(); -} TC[] = { - /* creat() the file and write to it */ - {filename, MODE1, functest1}, - - /* creat() the same file and check that it is now 0 length */ - {filename, MODE2, functest2} -}; - -int -main(int ac, char **av) -{ - int i; - int lc; /* loop counter */ - const 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, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - setup(); /* set "tstdir", and "testfile" variables */ - - /* check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - /* loop through the test cases */ - - for (i=0; i= 0) { - close(TEST_RETURN); - } - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * functest1() - check the functionality of the first test by making sure - * that a write to the file succeeds - */ -void -functest1() -{ - if (write(TEST_RETURN, "A", 1) != 1) { - tst_resm(TFAIL, "write was unsuccessful"); - } else { - tst_resm(TPASS, "file was created and written to successfully"); - } -} - -/* - * functest2() - check the functionality of the second test by making sure - * that the file is now 0 length - */ -void -functest2() -{ - struct stat buf; - - if (stat(filename, &buf) < 0) { - tst_brkm(TBROK, cleanup, "failed to stat test file"); - /*NOTREACHED*/ - } - if (buf.st_size != 0) { - tst_resm(TFAIL, "creat() FAILED to truncate " - "file to zero bytes"); - } else { - tst_resm(TPASS, "creat() truncated existing file to 0 bytes"); - } -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup() -{ - if (geteuid() == 0) { - tst_brkm(TBROK, tst_exit, "Must not run this as root"); - /*NOTREACHED*/ - } - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - umask(0); - - /* Pause if that option was specified */ - TEST_PAUSE; - - tst_tmpdir(); - - sprintf(filename, "creat01.%d", getpid()); -} - -/* - * 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; - - unlink(filename); - - /* delete the test directory created in setup() */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/creat03.c b/winsup/testsuite/winsup.api/ltp/creat03.c deleted file mode 100644 index 2ca21f1e0..000000000 --- a/winsup/testsuite/winsup.api/ltp/creat03.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * creat03.c - * - * DESCRIPTION - * Testcase to check whether the sticky bit cleared. - * - * ALGORITHM - * Creat a new file, fstat.st_mode should have the 01000 bit off - * - * USAGE: - * creat03 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -const char *TCID = "creat03"; /* Test program identifier */ -int TST_TOTAL = 1; /* Total number of test cases */ -extern int Tst_count; /* Test case counter */ - -char pfilname[40] = ""; -#define FMODE 0444 - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int ac, char **av) -{ - struct stat statbuf; - unsigned short filmode; - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - setup(); - - /* check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(creat(pfilname, FMODE)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "Cannot creat %s", pfilname); - continue; - /*NOTREACHED*/ - } - - if (STD_FUNCTIONAL_TEST) { - if (fstat(TEST_RETURN, &statbuf) == -1) { - tst_brkm(TBROK, cleanup, "fstat() failed"); - } - filmode = statbuf.st_mode; - tst_resm(TINFO, "Created file has mode = 0%o", filmode); - if ((filmode & S_ISVTX) != 0) { - tst_resm(TFAIL, "save text bit not cleared"); - } else { - tst_resm(TPASS, "save text bit cleared"); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - - if (TEST_RETURN >= 0) { - close(TEST_RETURN); - } - - /* clean up things in case we are looping */ - if (unlink(pfilname) == -1) { - tst_brkm(TBROK, cleanup, "couldn't remove file"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp dir and cd to it */ - tst_tmpdir(); - - sprintf(pfilname, "./creat4.%d", getpid()); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at completion or - * premature exit - */ -void -cleanup(void) -{ - TEST_CLEANUP; - - /* remove the tmp dir and all its files */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/creat09.c b/winsup/testsuite/winsup.api/ltp/creat09.c deleted file mode 100644 index c3c88a7c6..000000000 --- a/winsup/testsuite/winsup.api/ltp/creat09.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 521df6a78..000000000 --- a/winsup/testsuite/winsup.api/ltp/dup01.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - -const 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 */ - const 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 deleted file mode 100644 index ee759b89b..000000000 --- a/winsup/testsuite/winsup.api/ltp/dup02.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - -const 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 */ - const 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - -const char *TCID="dup03"; /* 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 *Fd = NULL; -int Nfds=0; - -/*********************************************************************** - * Main - ***********************************************************************/ -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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 dup(2) - */ - TEST( dup(Fd[0]) ); - - /* check return code */ - if ( TEST_RETURN == -1 ) { - if ( STD_FUNCTIONAL_TEST ) { - if ( TEST_ERRNO == EMFILE ) { - tst_resm(TPASS, "dup(%d) Failed, errno=%d : %s", Fd[0], - TEST_ERRNO, strerror(TEST_ERRNO)); - } - else { - tst_resm(TFAIL, "dup(%d) Failed, errno=%d %s, expected %d (EMFILE)", - Fd[0], TEST_ERRNO, strerror(TEST_ERRNO), EMFILE); - } - } - } else { - tst_resm(TFAIL, "dup(%d) returned %d, expected -1, errno:%d (EMFILE)", - Fd[0], TEST_RETURN, EMFILE); - - /* 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() -{ - long maxfds; - - /* - * Initialize Fd in case we get a quick signal - */ - maxfds = sysconf(_SC_OPEN_MAX); - if (maxfds < 1) { - tst_brkm(TBROK, cleanup, - "sysconf(_SC_OPEN_MAX) Failed, errno=%d : %s", - errno, strerror(errno)); - } - - Fd = (int *)malloc(maxfds*sizeof(int)); - 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; - - /* - * open the file as many times as it takes to use up all fds - */ - sprintf(Fname, "dupfile"); - for (Nfds=1; Nfds<=maxfds; Nfds++) { - if ((Fd[Nfds-1] = open(Fname,O_RDWR|O_CREAT,0700)) == -1) { - - Nfds--; /* on a open failure, decrement the counter */ - if ( errno == EMFILE ) { - break; - } - else { /* open failed for some other reason */ - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s", - Fname, errno, strerror(errno)); - } - } - } - - /* - * make sure at least one was open and that all fds were opened. - */ - if ( Nfds == 0 ) { - tst_brkm(TBROK, cleanup, "Unable to open at least one file"); - } - if ( Nfds > maxfds ) { - tst_brkm(TBROK, cleanup, - "Unable to open enough files to use all file descriptors, tried %d", - maxfds); - } -} /* 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) { - for (; Nfds >0 ; Nfds--) { - if (close(Fd[Nfds-1]) == -1) { - tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", - Fname, errno, strerror(errno)); - } - Fd[Nfds]=-1; - } - free(Fd); - } - - /* 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 deleted file mode 100644 index 1c4eaf188..000000000 --- a/winsup/testsuite/winsup.api/ltp/dup04.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - -const 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 */ - const 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 deleted file mode 100644 index 097688353..000000000 --- a/winsup/testsuite/winsup.api/ltp/dup05.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - -const 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 */ - const 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 deleted file mode 100644 index f91b0a820..000000000 --- a/winsup/testsuite/winsup.api/ltp/execl01.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * 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 -#include -#include - -#include -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index f7fcc8237..000000000 --- a/winsup/testsuite/winsup.api/ltp/execle01.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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 -#include -#include - -#include -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 383223c07..000000000 --- a/winsup/testsuite/winsup.api/ltp/execlp01.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * 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 -#include -#include - -#include -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index f59f29702..000000000 --- a/winsup/testsuite/winsup.api/ltp/execv01.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * 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 -#include - -#include -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -void cleanup(); - -const 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 */ -const char * const args[2]={"/usr/bin/test", 0}; /* argument list for execv call */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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 deleted file mode 100644 index 2584bdf05..000000000 --- a/winsup/testsuite/winsup.api/ltp/execve01.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * 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 -#include -#include - -#include -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ -const char *const 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 */ - const 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 deleted file mode 100644 index 8a1726a21..000000000 --- a/winsup/testsuite/winsup.api/ltp/execvp01.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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 -#include -#include - -#include -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ -const char *const args[2]={"/usr/bin/test", 0}; /* argument list for execvp call */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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/exit01.c b/winsup/testsuite/winsup.api/ltp/exit01.c deleted file mode 100644 index 74e6c093b..000000000 --- a/winsup/testsuite/winsup.api/ltp/exit01.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * exit01.c - * - * DESCRIPTION - * Check that exit returns the correct values to the waiting parent - * - * ALGORITHM - * Fork a process that immediately calls exit() with a known - * value. Check for that value in the parent. - * - * USAGE - * exit01 - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID = "exit01"; -int TST_TOTAL = 1; -extern int Tst_count; - -int -main(int ac, char **av) -{ - int pid, npid, sig, nsig, exno, nexno, status; - int rval = 0; - int lc; /* loop counter */ - const 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 PARSIkNG ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); /* global setup for test */ - - /* check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping. */ - Tst_count = 0; - - sig = 0; - exno = 1; - - if ((pid = fork()) == -1) { - tst_brkm(TBROK, cleanup, "fork failed, errno=%d", - errno, strerror(errno)); - } - - if (pid == 0) { /* parent */ - exit(exno); - } else { - sleep(1); /* let child start */ - npid = wait(&status); - - if (npid != pid) { - tst_resm(TFAIL, "wait error: " - "unexpected pid returned"); - rval = 1; - } - - nsig = status % 256; - - /* - * Check if the core dump bit has been set, bit # 7 - */ - if (nsig >= 128) { - nsig = nsig - 128; - } - - /* - * nsig is the signal number returned by wait - */ - if (nsig != sig) { - tst_resm(TFAIL, "wait error: " - "unexpected signal returned"); - rval = 1; - } - - /* - * nexno is the exit number returned by wait - */ - nexno = status / 256; - if (nexno != exno) { - tst_resm(TFAIL, "wait error: " - "unexpected exit number returned"); - rval = 1; - } - } - - if (rval != 1) { - tst_resm(TPASS, "exit() test PASSED"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup() -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - umask(0); - - /* Pause if that option was specified */ - TEST_PAUSE; -} - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/exit02.c b/winsup/testsuite/winsup.api/ltp/exit02.c deleted file mode 100644 index 1503106e9..000000000 --- a/winsup/testsuite/winsup.api/ltp/exit02.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * exit02.c - * - * DESCRIPTION - * Check that exit flushes output file buffers and closes files upon - * exitting - * - * ALGORITHM - * Fork a process that creates a file and writes a few bytes, and - * calls exit WITHOUT calling close(). The parent then reads the - * file. If everything that was written is present in the file, then - * the test passes. - * - * USAGE - * exit02 - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID = "exit02"; -int TST_TOTAL = 1; -extern int Tst_count; - -#define READ 0 -#define WRITE 1 -#define MODE 0666 - -char filen[40]; - -int -main(int ac, char **av) -{ - int pid, npid, sig, nsig, exno, nexno, status; - int filed; - char wbuf[BUFSIZ], rbuf[BUFSIZ]; - int len, rlen; - int rval = 0; - char *strcpy(); - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - setup(); /* global setup for test */ - - /* - * The following loop checks looping state if -i option given - */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* - * reset Tst_count in case we are looping. - */ - Tst_count = 0; - - strcpy(wbuf, "abcd"); - len = strlen(wbuf); - - exno = sig = 0; - - if ((pid = fork()) == -1) { - tst_brkm(TBROK, cleanup, "fork failed, error no = %d", - errno, strerror(errno)); - } - - if (pid == 0) { /* child */ - sleep(1); - if ((filed = creat(filen, MODE)) == -1) { - tst_resm(TINFO, "creat error: unable to" - "open output file"); - exit(2); - } - if (write(filed, wbuf, len) != len) { - tst_resm(TINFO, "write error"); - exit(2); - } - close(filed); - exit(exno); - } else { /* parent */ - npid = wait(&status); - - if (npid != pid) { - tst_resm(TFAIL, "wait error: " - "unexpected pid returned"); - rval = 1; - } - - nsig = status % 256; - - /* - * to check if the core dump bit has been - * set, bit # 7 - */ - if (nsig >= 128) - nsig = nsig - 128; - - /* - * nsig is the signal number returned by - * wait - */ - if (nsig != sig) { - tst_resm(TFAIL, "wait error: unexpected " - "signal returned %d", nsig); - rval = 1; - } - - /* - * nexno is the exit number returned by wait - */ - nexno = status / 256; - if (nexno != exno) { - tst_resm(TFAIL, "wait error: unexpected exit " - "number %d", nexno); - rval = 1; - } - - sleep(2); /* let child's exit close opened file */ - - filed = open(filen, O_RDONLY, READ); - if (filed == -1) { - tst_resm(TFAIL, "open error: " - "unable to open input file"); - rval = 1; - } else { - rlen = read(filed, rbuf, len); - if (len != rlen) { - tst_resm(TFAIL, "exit error: file " - "buffer was not flushed"); - rval = 1; - } else if (memcmp(rbuf, wbuf, rlen) != 0) { - tst_resm(TFAIL, "exit error: file " - "buffer was not flushed"); - rval = 1; - } - } - close(filed); - unlink(filen); - } - if (!rval) { - tst_resm(TPASS, "exit() test PASSED"); - } - } - cleanup(); - /*NOTREACHED*/ -} - -/* - * setup() - perform all ONE TIME setup for this test - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - umask(0); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - sprintf(filen, "tfile_%d",getpid()); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at completion or - * premature exit. - */ -void -cleanup(void) -{ - /* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/fchdir01.c b/winsup/testsuite/winsup.api/ltp/fchdir01.c deleted file mode 100644 index bd70c01b3..000000000 --- a/winsup/testsuite/winsup.api/ltp/fchdir01.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * fchdir01.c - * - * DESCRIPTION - * fchdir01 - create a directory and cd into it. - * - * ALGORITHM - * create a new directory - * open the directory and get a file descriptor - * loop if that option was specified - * fchdir() into the directory - * check the return code - * if failure, issue a FAIL message. - * otherwise, - * if doing functionality testing, call check_functionality() - * if correct, - * issue a PASS message - * otherwise - * issue a FAIL message - * call cleanup - * - * USAGE: - * fchdir01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 03/2001 - Written by Wayne Boyer - * - * RESTRICTIONS - * none - */ - -#include "test.h" -#include "usctest.h" - -#include -#include -#include -#include - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID = "fchdir01"; -int TST_TOTAL = 1; -extern int Tst_count; - -int fd = -1; -char temp_dir_buf [PATH_MAX]; -char* temp_dir; -const char *TEST_DIR = "alpha"; - -#define MODES S_IRWXU - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - void check_functionality(void); - int r_val; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - } - - setup(); /* global setup */ - - /* The following loop checks looping state if -i option given */ - - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - /* get the name of the test dirctory */ - if ((temp_dir = (getcwd(temp_dir_buf, sizeof (temp_dir_buf)))) == NULL) { - tst_brkm(TBROK, cleanup, "%s - getcwd() in main() " - "failed", TCID); - } - - /* - * create a new directory and open it - */ - - if ((r_val = mkdir(TEST_DIR, MODES)) == -1){ - tst_brkm(TBROK, cleanup, "%s - mkdir() in main() " - "failed", TCID); - } - - if ((fd = open(TEST_DIR, O_RDONLY)) == -1) { - tst_brkm(TBROK, cleanup, "open of directory failed"); - } - - /* - * Use TEST macro to make the call - */ - - TEST(fchdir(fd)); - - if (TEST_RETURN == -1) { - tst_brkm(TFAIL, cleanup, "%s call failed - errno = %d :" - " %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO)); - } else { - if (STD_FUNCTIONAL_TEST) { - check_functionality(); - } else { - tst_resm(TPASS, "call succeeded"); - } - } - - /* - * clean up things in case we are looping - */ - - /* - * NOTE: in case of failure here, we need to use "tst_resm()" - * and not "tst_brkm()". This is because if we get to this - * point, we have already set a PASS or FAIL for the test - * and "tst_brkm()" won't report as we might expect. - */ - - /* chdir back to our temporary work directory */ - if ((r_val = chdir("..")) == -1){ - tst_resm(TBROK, "fchdir failed - errno = %d : %s", - errno, strerror(errno)); - } - - if ((r_val = rmdir(TEST_DIR)) == -1){ - tst_resm(TBROK, "rmdir failed - errno = %d : %s", - errno, strerror(errno)); - } - - /* - * clean up things in case we are looping - */ - /* free(temp_dir); */ - temp_dir = NULL; - } - - cleanup(); - - /*NOTREACHED*/ -} - -/* - * check_functionality() - check that we are in the correct directory. - */ -void -check_functionality(void) -{ - char buf [PATH_MAX]; - char *cwd; - char **bufptr = &cwd; - char *dir; - - /* - * Get the current directory path. - */ - if ((cwd = (getcwd(buf, sizeof (buf)))) == NULL) { - tst_brkm(TBROK, cleanup, "%s - getcwd() in " - "check_functionality() failed", TCID); - } - - /* - * strip off all but the last directory name in the - * current working directory. - */ - do { - if ((dir = strsep(bufptr, "/")) == NULL) { - tst_brkm(TBROK, cleanup, "%s - strsep() in " - "check_functionality() failed", TCID); - } - } while(*bufptr != NULL); - - /* - * Make sure we are in the right place. - */ - if (strcmp(TEST_DIR, dir) == 0) { - tst_resm(TPASS, "%s call succeeded", TCID); - } else { - tst_resm(TFAIL, "%s functionality test failed", TCID); - } -} - -/* - * setup() - performs all the ONE TIME setup for this test. - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* create a test directory and cd into it */ - tst_tmpdir(); -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup(void) -{ - if (fd >= 0) - close (fd); - - /* remove the test directory */ - tst_rmdir(); - - /* - * 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(); -} - diff --git a/winsup/testsuite/winsup.api/ltp/fchdir02.c b/winsup/testsuite/winsup.api/ltp/fchdir02.c deleted file mode 100644 index 4e1d9e74a..000000000 --- a/winsup/testsuite/winsup.api/ltp/fchdir02.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * fchdir02.c - * - * DESCRIPTION - * fchdir02 - try to cd into a bad directory (bad fd). - * - * CALLS - * fchdir() - * - * ALGORITHM - * loop if that option was specified - * call fchdir() with an invalid file descriptor - * check the errno value - * issue a PASS message if we get EBADF - errno 9 - * otherwise, the tests fails - * issue a FAIL message - * break any remaining tests - * call cleanup - * - * USAGE: - * fchdir02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 03/2001 - Written by Wayne Boyer - * - * RESTRICTIONS - * none - */ - -#include "test.h" -#include "usctest.h" - -#include -#include -#include - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID = "fchdir02"; -int TST_TOTAL = 1; -extern int Tst_count; - -int exp_enos[] = {9, 0}; /* 0 terminated list of expected errnos */ - -int -main(int ac, char **av) -{ - const int bad_fd = -5; - int lc; /* loop counter */ - const 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); - } - - setup(); /* global setup */ - - /* The following loop checks looping state if -i option given */ - - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - /* - * Look for a failure by using an invalid number for fd - */ - - TEST(fchdir(bad_fd)); - - if (TEST_RETURN != -1) { - tst_brkm(TFAIL, cleanup, "call succeeded with bad " - "file descriptor"); - } - - TEST_ERROR_LOG(TEST_ERRNO); - - switch(TEST_ERRNO) { - case EBADF: - tst_resm(TPASS, "expected failure - errno = %d : %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - break; - default: - tst_brkm(TFAIL, cleanup, "call failed with an " - "unexpected error - %d : %s", TEST_ERRNO, - strerror(TEST_ERRNO)); - } - } - - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all the ONE TIME setup for this test. - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* create a test directory and cd into it */ - tst_tmpdir(); - - /* Set up the expected error numbers for -e option */ - TEST_EXP_ENOS(exp_enos); -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup(void) -{ - /* remove the test directory */ - tst_rmdir(); - - /* - * 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(); -} - diff --git a/winsup/testsuite/winsup.api/ltp/fchmod01.c b/winsup/testsuite/winsup.api/ltp/fchmod01.c deleted file mode 100644 index e2db7162a..000000000 --- a/winsup/testsuite/winsup.api/ltp/fchmod01.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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; -const char *buf = "davef"; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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 deleted file mode 100644 index d692bfc74..000000000 --- a/winsup/testsuite/winsup.api/ltp/fchown01.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * 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 -#include -#include - -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index cbdd08545..000000000 --- a/winsup/testsuite/winsup.api/ltp/fcntl02.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 8199469c3..000000000 --- a/winsup/testsuite/winsup.api/ltp/fcntl03.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 7af778936..000000000 --- a/winsup/testsuite/winsup.api/ltp/fcntl04.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 80cfe8c89..000000000 --- a/winsup/testsuite/winsup.api/ltp/fcntl05.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index d62eb7967..000000000 --- a/winsup/testsuite/winsup.api/ltp/fcntl07.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - * 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 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 -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" -#include "search_path.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); -void help(); - -const 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 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" -const char *File1 = DEFAULT_FILE; - -#define DEFAULT_SUBPROG "test_open" -const 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 - }; - -const char *testfdtypes[] = { - "regular file", - "write side of system pipe", - }; - -int test_open(const char *arg); -int do_exec(const char *prog, int fd, const char *tcd); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - int exec_return; /* return from do_exec */ - int **tcp; /* testcase pointer (pointer to FD) */ - const 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 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 - * ???? exit code from child: - * 2 BROK exec failed - * 0 PASS fd was properly closed - * - */ - -int -do_exec(const char *prog, int fd, const 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(const 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 deleted file mode 100644 index 405bf6127..000000000 --- a/winsup/testsuite/winsup.api/ltp/fcntl07B.c +++ /dev/null @@ -1,422 +0,0 @@ -/* - * 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 - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" -#include "search_path.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); -void help(); - -const 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 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" -const char *File1 = DEFAULT_FILE; - -#define DEFAULT_SUBPROG "test_open" -const char *openck = DEFAULT_SUBPROG; /* support program name to check for open FD */ -const char subprog_path[_POSIX_PATH_MAX];/* path to exec "openck" with */ -#define STRSIZE 255 -#define FIFONAME "FiFo" - -int *testfds[] = { - &npipe_fd, 0 - }; - -const char *testfdtypes[] = { - "named pipe" - }; - -int test_open(char *arg); -int do_exec(const char *prog, int fd, const char *tcd); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - int exec_return; /* return from do_exec */ - int **tcp; /* testcase pointer (pointer to FD) */ - const 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 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 - * ???? exit code from child: - * 2 BROK exec failed - * 0 PASS fd was properly closed - * - */ - -int -do_exec(const char *prog, int fd, const 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/fcntl08.c b/winsup/testsuite/winsup.api/ltp/fcntl08.c deleted file mode 100644 index eaf22436b..000000000 --- a/winsup/testsuite/winsup.api/ltp/fcntl08.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - -#ifndef O_NDELAY -#define O_NDELAY 0 -#endif - -const 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 */ - const 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 deleted file mode 100644 index 3a827e149..000000000 --- a/winsup/testsuite/winsup.api/ltp/fcntl09.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 0 - /* Ouch! Either read *or* write lock, but not both! - This code depends on F_RDLCK being 0. */ - flocks.l_type = F_RDLCK | F_WRLCK; -#else - flocks.l_type = F_WRLCK; -#endif - /* - * 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 deleted file mode 100644 index e2de44bef..000000000 --- a/winsup/testsuite/winsup.api/ltp/fcntl10.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 0 - /* Ouch! Either read *or* write lock, but not both! - This code depends on F_RDLCK being 0. */ - flocks.l_type = F_RDLCK | F_WRLCK; -#else - flocks.l_type = F_WRLCK; -#endif - /* - * 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 deleted file mode 100644 index 2aac2d427..000000000 --- a/winsup/testsuite/winsup.api/ltp/fork01.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#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" - - - -const 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 */ - const 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/fork02.c b/winsup/testsuite/winsup.api/ltp/fork02.c deleted file mode 100644 index eeec828ec..000000000 --- a/winsup/testsuite/winsup.api/ltp/fork02.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * fork02.c - * - * DESCRIPTION - * Test correct operation of fork: - * pid == 0 in child; - * pid > 0 in parent from wait; - * - * ALGORITHM - * Fork one process, check for pid == 0 in child. - * Check for pid > 0 in parent after wait. - * - * USAGE - * fork02 - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include "test.h" -#include "usctest.h" - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -const char *TCID = "fork02"; -int TST_TOTAL = 1; -extern int Tst_count; - -int -main(int ac, char **av) -{ - int pid1, pid2, status; - - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - /* - * perform global setup for the test - */ - setup(); - - /* - * check looping state if -i option is given - */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* - * reset Tst_count in case we are looping. - */ - Tst_count = 0; - - if ((pid1 = fork()) == -1) { - tst_brkm(TBROK, cleanup, "fork() failed"); - } - - if (pid1 == 0) { - tst_resm(TINFO, "Inside child"); - _exit(0); - } else { - tst_resm(TINFO, "Inside parent"); - pid2 = wait(&status); - tst_resm(TINFO, "exit status of wait %d", status); - - if (pid1 == pid2) { - tst_resm(TPASS, "test 1 PASSED"); - } else { - tst_resm(TFAIL, "test 1 FAILED"); - } - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; -} - -/* - * 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; - - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/fork03.c b/winsup/testsuite/winsup.api/ltp/fork03.c deleted file mode 100644 index fbc23bb37..000000000 --- a/winsup/testsuite/winsup.api/ltp/fork03.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * fork03.c - * - * DESCRIPTION - * Check that child can use a large text space and do a large - * number of operations. - * - * ALGORITHM - * Fork one process, check for pid == 0 in child. - * Check for pid > 0 in parent after wait. - * - * USAGE - * fork03 - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include "test.h" -#include "usctest.h" - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -const char *TCID = "fork03"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int ac, char **av) -{ - float fl1, fl2; - int i; - int pid1, pid2, status; - - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - /* - * perform global setup for the test - */ - setup(); - - /* - * check looping state if -i option is given - */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* - * reset Tst_count in case we are looping. - */ - Tst_count = 0; - - if ((pid1 = fork()) == -1) { - tst_brkm(TBROK, cleanup, "fork() failed"); - } - - if (pid1 == 0) { /* child */ - /* child uses some cpu cycles */ - for (i = 1; i < 32767; i++) { - fl1 = 0.000001; - fl1 = fl2 = 0.000001; - fl1 = fl1 * 10.0; - fl2 = fl1 / 1.232323; - fl1 = fl2 - fl2; - fl1 = fl2; - } - - /* Pid must always be zero in child */ - - if (pid1 != 0) { - exit(1); - } else { - exit(0); - } - } else { /* parent */ - tst_resm(TINFO, "process id in parent of child from " - "fork : %d", pid1); - pid2 = wait(&status); /* wait for child */ - - if (pid1 != pid2) { - tst_resm(TFAIL, "pids don't match : %d vs %d", - pid1, pid2); - continue; - } - - if ((status >> 8) != 0) { - tst_resm(TFAIL, "child exited with failure"); - continue; - } - - tst_resm(TPASS, "test 1 PASSED"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; -} - -/* - * 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; - - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/fork04.c b/winsup/testsuite/winsup.api/ltp/fork04.c deleted file mode 100644 index 84bac0579..000000000 --- a/winsup/testsuite/winsup.api/ltp/fork04.c +++ /dev/null @@ -1,403 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include /*Includes signal information. */ -#include -#include "test.h" -#include "usctest.h" - -const 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 */ -const char *environ_list[] = {"TERM","NoTSetzWq","TESTPROG"}; -#define NUMBER_OF_ENVIRON (int)(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: - * - ***********************************************************************/ -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 -#include "test.h" -#include "usctest.h" - -const char *TCID = "fork06"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -#define NUMFORKS 1000 - -int -main(int ac, char **av) -{ - int i, pid, status, childpid, succeed, fail; - - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - /* - * perform global setup for the test - */ - setup(); - - /* - * check looping state if -i option is given - */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* - * reset Tst_count in case we are looping. - */ - Tst_count = 0; - - succeed = 0; - fail = 0; - - for (i = 0; i < NUMFORKS; i++) { - if ((pid = fork()) == -1) { - fail++; - continue; - } - - if (pid == 0) { /* child */ - _exit(0); - } - - /* parent */ - childpid = wait(&status); - if (pid != childpid) { - tst_resm(TFAIL, "pid from wait %d", childpid); - } - succeed++; - } - - tst_resm(TINFO, "tries %d", i); - tst_resm(TINFO, "successes %d", succeed); - tst_resm(TINFO, "failures %d", fail); - - if ((wait(&status)) == -1) { - tst_resm(TINFO, "There were no children to wait for"); - } else { - tst_resm(TINFO, "There were children left"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; -} - -/* - * 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; - - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/fork07.c b/winsup/testsuite/winsup.api/ltp/fork07.c deleted file mode 100644 index 7e06db7a1..000000000 --- a/winsup/testsuite/winsup.api/ltp/fork07.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * fork07.c - * - * DESCRIPTION - * Check that all children inherit parent's file descriptor - * - * ALGORITHM - * Parent opens a file, writes to it; forks processes until - * -1 is returned. Each child attempts to read the file then returns. - * - * USAGE - * fork07 - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include "test.h" -#include "usctest.h" - -const char *TCID = "fork07"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -char pbuf[10]; -char fnamebuf[40]; - -int -main(int ac, char **av) -{ - int status, count, forks, pid1; - int ch_r_stat; - FILE *rea = NULL, *writ = NULL; - - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - /* - * perform global setup for the test - */ - setup(); - - /* - * check looping state if -i option is given - */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* - * reset Tst_count in case we are looping. - */ - Tst_count = 0; - - if ((writ = fopen(fnamebuf, "w")) == NULL) - tst_resm(TFAIL, "failed to fopen file for write"); - if ((rea = fopen(fnamebuf, "r")) == NULL) - tst_resm(TFAIL, "failed to fopen file for read"); - - fprintf(writ,"abcdefghijklmnopqrstuv") ; - fflush(writ); - sleep(1); - - if ((getc(rea)) != 'a') - tst_resm(TFAIL, "getc from read side was confused"); - - forks = 0; - -forkone: - ++forks; - pid1 = -1; - if ( forks >= 1000 || (pid1 = fork()) != 0) { /* parent */ - if (pid1 > 0) { - goto forkone; - } else if (pid1 < 0) { - tst_resm(TINFO, "last child forked"); - } - } else { /* child */ - ch_r_stat = getc(rea); -#ifdef DEBUG - tst_resm(TINFO, "Child got char: %c", ch_r_stat); - tst_resm(TINFO, "integer value of getc in child " - "expected %d got %d", 'b', ch_r_stat); -#endif - if (ch_r_stat != EOF) { /* for error or EOF */ - tst_resm(TPASS, "test passed in child no %d", - forks); - exit(0); - } else { - tst_resm(TFAIL, "Test failed in child no. %d", - forks); - exit(-1); - } - } - - /* parent */ - --forks; - for (count = 0; count <= forks; count++) { - wait(&status); -#ifdef DEBUG - tst_resm(TINFO, " exit status of wait " - " expected 0 got %d", status); -#endif - if (status == 0) { - tst_resm(TPASS, "parent test passed"); - } else { - tst_resm(TFAIL, "parent test failed"); - } - } - tst_resm(TINFO, "Number of processes forked is %d", forks); - } - fclose (writ); - fclose (rea); - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup() -{ - /* - * capture signals - */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - umask(0); - - /* - * Pause if that option was specified - */ - TEST_PAUSE; - - /* - * make a temp directory and cd to it - */ - tst_tmpdir(); - - strcpy(fnamebuf, "fork07."); - sprintf(pbuf, "%d", getpid()); - strcat(fnamebuf, pbuf); -} - -/* - * 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 - */ - unlink(fnamebuf); - tst_rmdir(); - - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/fork09.c b/winsup/testsuite/winsup.api/ltp/fork09.c deleted file mode 100644 index 233acc76e..000000000 --- a/winsup/testsuite/winsup.api/ltp/fork09.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * fork01.c - * - * DESCRIPTION - * Check that child has access to a full set of files. - * - * ALGORITHM - * Parent opens a maximum number of files - * Child closes one and attempts to open another, it should be - * available - * - * USAGE - * fork01 - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include /* for OPEN_MAX */ -#include -#include -#include -#include "test.h" -#include "usctest.h" - -const char *TCID = "fork01"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -char filname[40], childfile[40]; -int first; -FILE **fildeses; /* file streams */ -int mypid, nfiles; - -int -main(int ac, char **av) -{ - int pid, status, nf; - - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - /* - * perform global setup for the test - */ - setup(); - - fildeses = (FILE**)malloc((OPEN_MAX + 10) * sizeof(FILE *)); - if (fildeses == NULL) { - tst_brkm(TBROK, cleanup, "malloc failed"); - /*NOTREACHED*/ - } - - /* - * check looping state if -i option is given - */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* - * reset Tst_count in case we are looping. - */ - Tst_count = 0; - - mypid = getpid(); - - tst_resm(TINFO, "OPEN_MAX is %d", OPEN_MAX); - - /* establish first free file */ - sprintf(filname, "fork01.%d", mypid); - if ((first = creat(filname, 0660)) == -1) { - tst_brkm(TBROK, cleanup, "Cannot open first file %s, " - "errno = %d", filname, errno); - /*NOTREACHED*/ - } - close(first); - - tst_resm(TINFO, "first file descriptor is %d ", first); - - if (unlink(filname) == -1) { - tst_brkm(TBROK, cleanup, "Cannot unlink file %s, " - "errno = %d", filname, errno); - /*NOTREACHED*/ - } - - /* - * now open all the files for the test - */ - for (nfiles = first; nfiles < OPEN_MAX; nfiles++) { - sprintf(filname, "file%d.%d", nfiles, mypid); - if ((fildeses[nfiles] = fopen(filname, "a")) == NULL) { - tst_brkm(TBROK, cleanup, "Parent: cannot open " - "file %d %s errno = %d", nfiles, - filname, errno); - /*NOTREACHED*/ - } -#ifdef DEBUG - tst_resm(TINFO, "filname: %s", filname); -#endif - } - - tst_resm(TINFO, "Parent reporting %d files open", nfiles - 1); - - if ((pid = fork()) == -1) { - tst_brkm(TBROK, cleanup, "Fork failed"); - /*NOTREACHED*/ - } - - if (pid == 0) { /* child */ - nfiles--; - if (fclose(fildeses[nfiles]) == -1) { - tst_resm(TINFO, "Child could not close file " - "#%d, errno = %d", nfiles, errno); - exit(1); - /*NOTREACHED*/ - } else { - sprintf(childfile, "cfile.%d", getpid()); - if ((fildeses[nfiles] = - fopen(childfile, "a")) == NULL) { - tst_resm(TINFO, "Child could not open " - "file %s, errno = %d", - childfile, errno); - exit(1); - /*NOTREACHED*/ - } else { - tst_resm(TINFO, "Child opened new " - "file #%d", nfiles); - unlink(childfile); - exit(0); - } - } - } else { /* parent */ - wait(&status); - if (status >> 8 != 0) { - tst_resm(TFAIL, "test 1 FAILED"); - } else { - tst_resm(TPASS, "test 1 PASSED"); - } - } - - /* clean up things in case we are looping */ - for (nf = first; nf < nfiles; nf++) { - fclose(fildeses[nf]); - sprintf(filname, "file%d.%d", nf, mypid); - unlink(filname); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup() -{ - /* - * capture signals - */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - umask(0); - - /* - * Pause if that option was specified - */ - TEST_PAUSE; - - /* - * make a temp directory and cd to it - */ - tst_tmpdir(); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or at 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(); - - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/fork10.c b/winsup/testsuite/winsup.api/ltp/fork10.c deleted file mode 100644 index 9dcbbb3b5..000000000 --- a/winsup/testsuite/winsup.api/ltp/fork10.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * fork04.c - * - * DESCRIPTION - * Check inheritance of file descriptor by children, they - * should all be refering to the same file. - * - * ALGORITHM - * Child reads several chars and exits. - * Parent forks another child, have the child and parent attempt to use - * that location - * - * USAGE - * fork04 - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include -#include "test.h" -#include "usctest.h" - -const char *TCID = "fork04"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -char pidbuf[10]; -char fnamebuf[40]; - -int -main(int ac, char **av) -{ - int status, pid, fildes; - char parchar[2]; - char chilchar[2]; - - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - /* - * perform global setup for the test - */ - setup(); - - /* - * check looping state if -i option is given - */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* - * reset Tst_count in case we are looping. - */ - Tst_count = 0; - - if ((fildes = creat(fnamebuf, 0600)) < 0) { - tst_brkm(TBROK, cleanup, "Parent: cannot open %s for " - "write, errno = %d", fnamebuf, errno); - /*NOTREACHED*/ - } - write(fildes, "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n", 27); - close(fildes); - - if ((fildes = open(fnamebuf, 0)) == -1) { - tst_brkm(TBROK, cleanup, "Parent: cannot open %s for " - "reading", fnamebuf); - /*NOTREACHED*/ - } - - if ((pid = fork()) == -1) { - tst_brkm(TBROK, cleanup, "fork() #1 failed"); - /*NOTREACHED*/ - } - - if (pid == 0) { /* child */ - tst_resm(TINFO, "fork child A"); - if (lseek(fildes, 10L, 0) == -1L) { - tst_resm(TFAIL, "bad lseek by child"); - exit(1); - } - exit(0); - } else { /* parent */ - wait(&status); - - /* parent starts second child */ - if ((pid = fork()) == -1) { - tst_brkm(TBROK, cleanup, "fork() #2 failed"); - /*NOTREACHED*/ - } - - if (pid == 0) { /* child */ - if (read(fildes, chilchar, 1) <= 0) { - tst_resm(TFAIL, "Child can't read " - "file"); - exit(1); - } else { - if (chilchar[0] != 'K') { - chilchar[1] = '\n'; - exit(1); - } else { - exit(0); - } - } - } else { /* parent */ - (void)wait(&status); - if (status >> 8 != 0) { - tst_resm(TFAIL, "Bad return from " - "second child"); - continue; - } - /* parent reads */ - if (read(fildes, parchar, 1) <= 0) { - tst_resm(TFAIL, "Parent cannot read " - "file"); - continue; - } else { - write(fildes, parchar, 1); - if (parchar[0] != 'L') { - parchar[1] = '\n'; - tst_resm(TFAIL, "Test failed"); - continue; - } - } - } - } - tst_resm(TPASS, "test 1 PASSED"); - close (fildes); - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup() -{ - /* - * capture signals - */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - umask(0); - - /* - * Pause if that option was specified - */ - TEST_PAUSE; - - /* - * make a temp directory and cd to it - */ - tst_tmpdir(); - - strcpy(fnamebuf, "fork04."); - sprintf(pidbuf, "%d", getpid()); - strcat(fnamebuf, pidbuf); -} - -/* - * 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(); - - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/fork11.c b/winsup/testsuite/winsup.api/ltp/fork11.c deleted file mode 100644 index 2b1035230..000000000 --- a/winsup/testsuite/winsup.api/ltp/fork11.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * fork05.c - * - * DESCRIPTION - * Test that parent gets a pid from each child when doing wait - * - * ALGORITHM - * Fork NUMFORKS children that do nothing. - * - * USAGE - * fork05 - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include "test.h" -#include "usctest.h" - -const char *TCID = "fork05"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -#define NUMFORKS 100 - -int -main(int ac, char **av) -{ - int i, pid, cpid, status; - - int lc; /* loop counter */ - const 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); - /*NOTREACHED*/ - } - - /* - * perform global setup for the test - */ - setup(); - - /* - * check looping state if -i option is given - */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* - * reset Tst_count in case we are looping. - */ - Tst_count = 0; - - for (i=0; i 0) { /* parent */ - cpid = wait(&status); - if (cpid == pid) { - tst_resm(TPASS, "fork #%d passed", i+1); - } else { - tst_resm(TFAIL, "fork #%d failed", i+1); - } - } else { - tst_resm(TFAIL, "fork #%d failed", i+1); - break; - } - } - tst_resm(TINFO, "Number of processes forked = %d", i); - tst_resm(TINFO, "Exit test 1"); - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; -} - -/* - * 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; - - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/fpathconf01.c b/winsup/testsuite/winsup.api/ltp/fpathconf01.c deleted file mode 100644 index 37fbe9689..000000000 --- a/winsup/testsuite/winsup.api/ltp/fpathconf01.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 -{ - const 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 */ - const 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - -const 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 */ - const 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/fstat02.c b/winsup/testsuite/winsup.api/ltp/fstat02.c deleted file mode 100644 index 224caf0d7..000000000 --- a/winsup/testsuite/winsup.api/ltp/fstat02.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: fstat02 - * - * Test Description: - * Verify that, fstat(2) succeeds to get the status of a file and fills - * the stat structure elements though file pointed to by file descriptor - * not opened for reading. - * - * Expected Result: - * fstat() should return value 0 on success and the stat structure elements - * should be filled with specified 'file' information. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * fstat02 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * This test should be run by 'non-super-user' only. - * - */ -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define FILE_MODE 0644 -#define TESTFILE "testfile" -#define FILE_SIZE 1024 -#define BUF_SIZE 256 -#define MASK 0777 - -const char *TCID="fstat02"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -uid_t User_id; /* user id/group id of test process */ -gid_t Group_id; -int fildes; /* File descriptor of testfile */ - -void setup(); /* Setup function for the test */ -void cleanup() __attribute__((noreturn));/* Cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat structure buffer */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count = 0; - - /* - * Call fstat(2) to get the status of - * specified 'file' pointed to by 'fd' - * into stat structure. - */ - TEST(fstat(fildes, &stat_buf)); - - /* check return code of fstat(2) */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "fstat on %s Failed, errno=%d : %s", - TESTFILE, TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Verify the data returned by fstat(2) - * aganist the expected data. - */ - if ((stat_buf.st_uid != User_id) || - (stat_buf.st_gid != Group_id) || - (stat_buf.st_size != FILE_SIZE) || - ((stat_buf.st_mode & MASK) != FILE_MODE)) { - tst_resm(TFAIL, "Functionality of fstat(2) on " - "'%s' Failed", TESTFILE); - } else { - tst_resm(TPASS, "Functionality of fstat(2) on " - "'%s' Succcessful", TESTFILE); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * void - * setup() - Performs setup function for the test. - * Creat a temporary directory and chdir to it. - * Creat a temporary file and write some known data into it. - * Get the effective uid/gid of test process. - */ -void -setup() -{ - int i; - char tst_buff[BUF_SIZE]; - int wbytes; - int write_len = 0; - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Check that the test process id is not super/root */ - if (geteuid() == 0) { - tst_brkm(TBROK, NULL, "Must be non-super/root for this test!"); - tst_exit(); - } - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - if ((fildes = open(TESTFILE, O_WRONLY|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - } - - /* Fill the test buffer with the known data */ - for (i = 0; i < BUF_SIZE; i++) { - tst_buff[i] = 'a'; - } - - /* Write to the file 1k data from the buffer */ - while (write_len < FILE_SIZE) { - if ((wbytes = write(fildes, tst_buff, sizeof(tst_buff))) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } else { - write_len += wbytes; - } - } - - /* Get the uid/gid of the process */ - User_id = getuid(); - Group_id = getgid(); - -} /* End setup() */ - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Close the test file and remove the test file and temporary directory. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Close the test file */ - if (close(fildes) == -1) { - tst_brkm(TFAIL, NULL, "close(%s) Failed, errno=%d : %s", - TESTFILE, 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/fstat03.c b/winsup/testsuite/winsup.api/ltp/fstat03.c deleted file mode 100644 index 47982ed47..000000000 --- a/winsup/testsuite/winsup.api/ltp/fstat03.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Test Name: fstat03 - * - * Test Description: - * Verify that, fstat(2) returns -1 and sets errno to EBADF if the file - * pointed to by file descriptor is not valid. - * - * Expected Result: - * fstat() should fail with return value -1 and set expected errno. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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) - * if errno set == expected errno - * Issue sys call fails with expected return value and errno. - * Otherwise, - * Issue sys call fails with unexpected errno. - * Otherwise, - * Issue sys call returns unexpected value. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory(s)/file(s) created. - * - * Usage: - * fstat03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * This test should be executed by 'non-super-user' only. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define TEST_FILE "testfile" - -const char *TCID="fstat03"; /* 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[]={EBADF, 0}; -int fildes; /* testfile descriptor */ - -void setup(); /* Main setup function for the tests */ -void cleanup() __attribute__((noreturn));/* cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat structure buffer */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* - * Invoke setup function to create a testfile under temporary - * directory. - */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - /* - * Call fstat(2) to get the status information - * of a closed testfile pointed to by 'fd'. - * verify that fstat fails with -1 return value and - * sets appropriate errno. - */ - TEST(fstat(fildes, &stat_buf)); - - /* Check return code from fstat(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO == EBADF) { - tst_resm(TPASS, "fstat() fails with " - "expected error EBADF"); - } else { - tst_resm(TFAIL, "fstat() fails with " - "wrong errno:%d", TEST_ERRNO); - } - } else { - tst_resm(TFAIL, "fstat() returned %d, " - "expected -1, error EBADF"); - } - } /* End for TEST_LOOPING */ - - /* - * Invoke cleanup() to delete the test directory/file(s) created - * in the setup(). - */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * void - * setup(void) - performs all ONE TIME setup for this test. - * Exit the test program on receipt of unexpected signals. - * Create a temporary directory and change directory to it. - * Create a testfile under temporary directory. - * Close the testfile. - */ -void -setup() -{ - /* Capture unexpected signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Make a temp dir and cd to it */ - tst_tmpdir(); - - /* Create a testfile under temporary directory */ - if ((fildes = open(TEST_FILE, O_RDWR|O_CREAT, 0666)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, 0666) failed, errno=%d : %s", - TEST_FILE, errno, strerror(errno)); - } - - if (close(fildes) == -1) { - tst_brkm(TBROK, cleanup, - "close(%s) Failed, errno=%d : %s", - TEST_FILE, errno, strerror(errno)); - } -} /* End of setup */ - -/* - * void - * cleanup() - Performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Print test timing stats and errno log if test executed with options. - * Close the testfile if still opened. - * Remove temporary directory and sub-directories/files under it - * created during setup(). - * Exit the test program with normal exit code. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Remove files and temporary directory created */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} /* End cleanup() */ diff --git a/winsup/testsuite/winsup.api/ltp/fstat04.c b/winsup/testsuite/winsup.api/ltp/fstat04.c deleted file mode 100644 index 1de507e62..000000000 --- a/winsup/testsuite/winsup.api/ltp/fstat04.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: fstat01 - * - * Test Description: - * Verify that, fstat(2) succeeds to get the status of a file pointed by - * file descriptor and fills the stat structure elements. - * - * Expected Result: - * fstat() should return value 0 on success and the stat structure should - * be filled with specified 'file' information. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * fstat01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * This test should be run by 'non-super-user' only. - * - */ -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define FILE_MODE 0644 -#define TESTFILE "testfile" -#define FILE_SIZE 1024 -#define BUF_SIZE 256 -#define MASK 0777 - -const 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 */ -uid_t User_id; /* user id/group id of test process */ -gid_t Group_id; -int fildes; /* File descriptor of testfile */ - -void setup(); /* Setup function for the test */ -void cleanup() __attribute__((noreturn));/* Cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat structure buffer */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count = 0; - - /* - * Call fstat(2) to get the status of - * specified 'file' pointed to 'fd' - * into stat structure. - */ - TEST(fstat(fildes, &stat_buf)); - - /* check return code of fstat(2) */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "fstat on %s Failed, errno=%d : %s", - TESTFILE, TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Verify the data returned by fstat(2) - * aganist the expected data. - */ - if ((stat_buf.st_uid != User_id) || - (stat_buf.st_gid != Group_id) || - (stat_buf.st_size != FILE_SIZE) || - ((stat_buf.st_mode & MASK) != FILE_MODE)) { - tst_resm(TFAIL, "Functionality of fstat(2) on " - "'%s' Failed", TESTFILE); - } else { - tst_resm(TPASS, "Functionality of fstat(2) on " - "'%s' Succcessful", TESTFILE); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * void - * setup() - Performs setup function for the test. - * Creat a temporary directory and chdir to it. - * Creat a test file and write some data into it. - * Get the user/group id info. of test process. - */ -void -setup() -{ - int i; /* counter */ - char tst_buff[BUF_SIZE]; /* data buffer */ - int wbytes; /* no. of bytes written */ - int write_len = 0; /* data length */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Check that the test process id is not super/root */ - if (geteuid() == 0) { - tst_brkm(TBROK, NULL, "Must be non-super/root for this test!"); - tst_exit(); - } - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - if ((fildes = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - } - - /* Fill the test buffer with the known data */ - for (i = 0; i < BUF_SIZE; i++) { - tst_buff[i] = 'a'; - } - - /* Write to the file 1k data from the buffer */ - while (write_len < FILE_SIZE) { - if ((wbytes = write(fildes, tst_buff, sizeof(tst_buff))) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } else { - write_len += wbytes; - } - } - - /* Get the uid/gid of the process */ - User_id = getuid(); - Group_id = getgid(); - -} /* End setup() */ - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Close the testfile opened for reading/writing. - * Delete the testfile and temporary directory. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Close the test file */ - if (close(fildes) == -1) { - tst_brkm(TFAIL, NULL, "close(%s) Failed, errno=%d : %s", - TESTFILE, 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 deleted file mode 100644 index 261ea0dbb..000000000 --- a/winsup/testsuite/winsup.api/ltp/fsync01.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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; -const char *buf = "davef"; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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/ftruncate01.c b/winsup/testsuite/winsup.api/ltp/ftruncate01.c deleted file mode 100644 index a45c167aa..000000000 --- a/winsup/testsuite/winsup.api/ltp/ftruncate01.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: ftruncate01 - * - * Test Description: - * Verify that, ftruncate(2) succeeds to truncate a file to a specified - * length if the file indicated by file descriptor opened for writing. - * - * Expected Result: - * ftruncate(2) should return a value 0 and the length of the file after - * truncation should be equal to the length it is truncated to. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * ftruncate01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * This test should be run by 'non-super-user' only. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TESTFILE "testfile" /* file under test */ -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define BUF_SIZE 256 /* buffer size */ -#define FILE_SIZE 1024 /* test file size */ -#define TRUNC_LEN 256 /* truncation length */ - -const char *TCID="ftruncate01"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test conditions */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -int fildes; /* file descriptor for test file */ - -void setup(); /* setup function for the test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat(2) struct contents */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - off_t file_length; /* test file length */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count = 0; - - /* - * Call ftruncate(2) to truncate a test file to a - * specified length. - */ - TEST(ftruncate(fildes, TRUNC_LEN)); - - /* check return code of ftruncate(2) */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "ftruncate() of %s Failed, errno=%d : %s", - TESTFILE, TEST_ERRNO, - strerror(TEST_ERRNO)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Get the testfile information using - * fstat(2). - */ - if (fstat(fildes, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, - "stat(2) of %s failed, error:%d", - TESTFILE, errno); - } - stat_buf.st_mode &= ~S_IFREG; - file_length = stat_buf.st_size; - - /* - * Check for expected size of testfile after - * truncate(2) on it. - */ - if (file_length != TRUNC_LEN) { - tst_resm(TFAIL, "%s: Incorrect file size %d, " - "Expected %d", TESTFILE, file_length, - TRUNC_LEN); - } else { - tst_resm(TPASS, "Functionality of ftruncate() " - "on %s successful", TESTFILE); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and write some - * data into it. - */ -void -setup() -{ - int i; /* counter for for loop() */ - int c, c_total = 0; /* bytes to be written to file */ - char tst_buff[BUF_SIZE]; /* buffer to hold data */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Fill the test buffer with the known data */ - for (i = 0; i < BUF_SIZE; i++) { - tst_buff[i] = 'a'; - } - - /* open a file for reading/writing */ - if ((fildes = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - } - - /* Write to the file 1k data from the buffer */ - while (c_total < FILE_SIZE) { - if ((c = write(fildes, tst_buff, sizeof(tst_buff))) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } else { - c_total += c; - } - } -} /* End setup() */ - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Close the temporary file. - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - */ - TEST_CLEANUP; - - /* Close the testfile after writing data into it */ - if (close(fildes) == -1) { - tst_brkm(TFAIL, NULL, - "close(%s) Failed, errno=%d : %s", - TESTFILE, 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/ftruncate02.c b/winsup/testsuite/winsup.api/ltp/ftruncate02.c deleted file mode 100644 index 2b4e72326..000000000 --- a/winsup/testsuite/winsup.api/ltp/ftruncate02.c +++ /dev/null @@ -1,313 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: ftruncate02 - * - * Test Description: - * Verify that, ftruncate(2) succeeds to truncate a file to a certain length, - * but the attempt to read past the truncated length will fail. - * - * Expected Result: - * ftruncate(2) should return a value 0 and the attempt to read past the - * truncated length will fail. In case where the file before truncation was - * shorter, the bytes between the old and new should be all zeroes. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * ftruncate02 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * This test should be run by 'non-super-user' only. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TESTFILE "testfile" /* file under test */ -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define BUF_SIZE 256 /* buffer size */ -#define FILE_SIZE 1024 /* test file size */ -#define TRUNC_LEN1 256 /* truncation length */ -#define TRUNC_LEN2 512 /* truncation length */ - -const char *TCID="ftruncate02"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test conditions */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -int fd; /* file descriptor of testfile */ -char tst_buff[BUF_SIZE]; /* buffer to hold testfile contents */ - -void setup(); /* setup function for the test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat(2) struct contents */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - off_t file_length2; /* test file length */ - off_t file_length1; /* test file length */ - int rbytes, i; /* bytes read from testfile */ - int read_len = 0; /* total no. of bytes read from testfile */ - int err_flag = 0; /* error indicator flag */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count = 0; - - /* - * Call ftruncate(2) to truncate a test file to a - * specified length (TRUNC_LEN1). - */ - TEST(ftruncate(fd, TRUNC_LEN1)); - - /* check return code of ftruncate(2) */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "ftruncate of %s to size %d Failed, " - "errno=%d : %s", TESTFILE, TRUNC_LEN1, - TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Get the testfile information using - * fstat(2). - */ - if (fstat(fd, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, "fstat(2) of %s failed" - " after 1st truncate, error:%d", - TESTFILE, errno); - } - stat_buf.st_mode &= ~S_IFREG; - file_length1 = stat_buf.st_size; - - /* - * Set the file pointer of testfile to the - * beginning of the file. - */ - if (lseek(fd, 0, SEEK_SET) < 0) { - tst_brkm(TFAIL, cleanup, "lseek(2) on %s failed" - " after 1st ftruncate, error:%d", - TESTFILE, errno); - } - - /* Read the testfile from the beginning. */ - while ((rbytes = read(fd, tst_buff, - sizeof(tst_buff))) > 0) { - read_len += rbytes; - } - - /* - * Execute ftruncate(2) again to truncate - * testfile to a size TRUNC_LEN2. - */ - TEST(ftruncate(fd, TRUNC_LEN2)); - - /* check return code of ftruncate(2) */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "ftruncate of %s to size %d " - "Failed, errno=%d : %s", TESTFILE, - TRUNC_LEN2, TEST_ERRNO, - strerror(TEST_ERRNO)); - continue; - } - - /* - * Get the testfile information using - * fstat(2) - */ - if (fstat(fd, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, "fstat(2) of %s failed" - " after 2nd truncate, error:%d", - TESTFILE, errno); - } - stat_buf.st_mode &= ~S_IFREG; - file_length2 = stat_buf.st_size; - - /* - * Set the file pointer of testfile to the - * offset TRUNC_LEN1 of testfile. - */ - if (lseek(fd, TRUNC_LEN1, SEEK_SET) < 0) { - tst_brkm(TFAIL, cleanup, "lseek(2) on %s failed" - " after 2nd ftruncate, error:%d", - TESTFILE, errno); - } - - /* Read the testfile contents till EOF */ - while((rbytes = read(fd, tst_buff, - sizeof(tst_buff))) > 0) { - for (i = 0; i < rbytes; i++) { - if (tst_buff[i] != 0) { - err_flag++; - } - } - } - - /* - * Check for expected size of testfile after - * issuing ftruncate(2) on it. - */ - if ((file_length1 != TRUNC_LEN1) || - (file_length2 != TRUNC_LEN2) || - (read_len != TRUNC_LEN1) || - (err_flag != 0)) { - tst_resm(TFAIL, "Functionality of ftruncate(2) " - "on %s Failed", TESTFILE); - } else { - tst_resm(TPASS, "Functionality of ftruncate(2) " - "on %s successful", TESTFILE); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and write some - * data into it. - */ -void -setup() -{ - int i; /* counter variable */ - int wbytes; /* bytes written to testfile */ - int write_len = 0; /* total no. of bytes written to testfile */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Fill the test buffer with the known data */ - for (i = 0; i < BUF_SIZE; i++) { - tst_buff[i] = 'a'; - } - /* open a file for reading/writing */ - if ((fd = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - } - - /* Write to the file 1k data from the buffer */ - while (write_len < FILE_SIZE) { - if ((wbytes = write(fd, tst_buff, sizeof(tst_buff))) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } else { - write_len += wbytes; - } - } -} /* End setup() */ - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Close the testfile. - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - */ - TEST_CLEANUP; - - /* Close the testfile after writing data into it */ - if (close(fd) == -1) { - tst_brkm(TFAIL, NULL, "close(%s) Failed, errno=%d : %s", - TESTFILE, 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/ftruncate03.c b/winsup/testsuite/winsup.api/ltp/ftruncate03.c deleted file mode 100644 index 279b4e88f..000000000 --- a/winsup/testsuite/winsup.api/ltp/ftruncate03.c +++ /dev/null @@ -1,324 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: ftruncate03 - * - * Test Description: - * Verify that, - * 1) ftruncate(2) returns -1 and sets errno to EINVAL if the specified - * truncate length is less than 0. - * 2) ftruncate(2) returns -1 and sets errno to EBADF if the file descriptor - * of the specified file is not valid. - * - * Expected Result: - * ftruncate() should fail with return value -1 and set expected errno. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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) - * if errno set == expected errno - * Issue sys call fails with expected return value and errno. - * Otherwise, - * Issue sys call fails with unexpected errno. - * Otherwise, - * Issue sys call returns unexpected value. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory(s)/file(s) created. - * - * Usage: - * ftruncate03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * This test should be executed by 'non-super-user' only. - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEST_FILE1 "test_file1" /* file under test */ -#define TEST_FILE2 "test_file2" /* file under test */ -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define BUF_SIZE 256 /* buffer size */ -#define FILE_SIZE 1024 /* test file size */ - -int no_setup(); -int setup1(); /* setup function to test chmod for EBADF */ -int setup2(); /* setup function to test chmod for EINVAL */ - -int fd1; /* File descriptor for testfile1 */ -int fd2; /* File descriptor for testfile2 */ - -struct test_case_t { /* test case struct. to hold ref. test cond's*/ - int fd; - const char *desc; - int exp_errno; - int len; - int (*setupfunc)(); -} Test_cases[] = { - { 1, "Length argument is -ve", EINVAL, -1, setup1 }, - { 2, "File descriptor is not valid", EBADF, 256, setup2 }, - { 0, NULL, 0, 0, no_setup } -}; - -const char *TCID="ftruncate03"; /* Test program identifier. */ -int TST_TOTAL=2; /* Total number of test conditions */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -int exp_enos[]={EINVAL, EBADF, 0}; - -void setup(); /* Main setup function for the test */ -void cleanup(void) __attribute__((noreturn)); /* Main cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - const char *test_desc; /* test specific error message */ - int fildes; /* File descriptor of testfile */ - off_t trunc_len; /* truncate length */ - int ind; - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* - * Perform global setup for test to call individual test specific - * setup functions. - */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Check looping state if -i 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++) { - fildes = Test_cases[ind].fd; - test_desc = Test_cases[ind].desc; - trunc_len = Test_cases[ind].len; - - if (fildes == 1) { - fildes = fd1; - } else { - fildes = fd2; - } - - /* - * Call ftruncate(2) to test different test conditions. - * verify that it fails with return code -1 and sets - * appropriate errno. - */ - TEST(ftruncate(fildes, trunc_len)); - - /* check return code of ftruncate(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO == Test_cases[ind].exp_errno) { - tst_resm(TPASS, "ftruncate() fails, %s," - " errno=%d", test_desc, - TEST_ERRNO); - } else { - tst_resm(TFAIL, "ftruncate() fails, %s," - " errno=%d, expected errno:%d", - test_desc, TEST_ERRNO, - Test_cases[ind].exp_errno); - } - } else { - tst_resm(TFAIL, "ftruncate() returned %d, " - "expected -1, errno:%d", TEST_RETURN, - Test_cases[ind].exp_errno); - } - } /* End of TEST CASE LOOPING. */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Fill the test buffer with some date used to fill test file(s). - * Call individual test specific setup functions. - */ -void -setup() -{ - int ind; - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Check that the test process id is not root/super-user */ - if (geteuid() == 0) { - tst_brkm(TBROK, NULL, "Must be non-root/super for this test!"); - tst_exit(); - } - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* call individual setup functions */ - for (ind = 0; Test_cases[ind].desc != NULL; ind++) { - Test_cases[ind].setupfunc(); - } -} /* End of setup */ - -/* - * int - * setup1() - setup function for a test condition for which ftruncate(2) - * returns -1 and sets errno to EINVAL. - * Create a test file and open it for writing only. - */ -int -setup1() -{ - /* Open the testfile in write-only mode */ - if ((fd1 = open(TEST_FILE1, O_WRONLY|O_CREAT, 0644)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_WRONLY) Failed, errno=%d : %s", - TEST_FILE1, errno, strerror(errno)); - } - return 0; -} /* End setup1() */ - -/* - * int - * setup2() - setup function for a test condition for which ftruncate(2) - * returns -1 and sets errno to EBADF. - * Create a test file and open it for reading/writing, and fill the - * testfile with the contents of test buffer. - * Close the test file. - * - */ -int -setup2() -{ - int c, i, c_total = 0; - char tst_buff[BUF_SIZE]; /* buffer to hold testfile contents */ - - /* Fill the test buffer with the known data */ - for (i = 0; i < BUF_SIZE; i++) { - tst_buff[i] = 'a'; - } - - /* open a testfile for reading/writing */ - if ((fd2 = open(TEST_FILE2, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %o) Failed, errno=%d : %s", - TEST_FILE2, FILE_MODE, errno, strerror(errno)); - } - - /* Write to the file 1k data from the buffer */ - while (c_total < FILE_SIZE) { - if ((c = write(fd2, tst_buff, sizeof(tst_buff))) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TEST_FILE2, errno, strerror(errno)); - } else { - c_total += c; - } - } - - /* Close the testfile after writing data into it */ - if (close(fd2) == -1) { - tst_brkm(TBROK, cleanup, - "close(%s) Failed, errno=%d : %s", - TEST_FILE2, errno, strerror(errno)); - } - return 0; -} /* End of setup2 */ - -/* - * int - * no_setup() - This function just returns 0. - */ -int -no_setup() -{ - return 0; -} - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Close the temporary file. - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - */ - TEST_CLEANUP; - - /* Close the testfile after opening it read-only in setup1 */ - if (close(fd1) == -1) { - tst_brkm(TFAIL, NULL, - "close(%s) Failed, errno=%d : %s", - TEST_FILE1, 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 deleted file mode 100644 index 942201067..000000000 --- a/winsup/testsuite/winsup.api/ltp/getegid01.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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 -#include -#include - -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 82a681ec5..000000000 --- a/winsup/testsuite/winsup.api/ltp/geteuid01.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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 -#include -#include - -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index e5b138c8a..000000000 --- a/winsup/testsuite/winsup.api/ltp/getgid01.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/getgid02.c b/winsup/testsuite/winsup.api/ltp/getgid02.c deleted file mode 100644 index 5efbda521..000000000 --- a/winsup/testsuite/winsup.api/ltp/getgid02.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * getgid02.c - * - * DESCRIPTION - * Testcase to check the basic functionality of getegid(). - * - * ALGORITHM - * call setup - * loop if that option was specified - * Execute getegid() call using TEST macro - * if not expected value - * break remaining tests and cleanup - * if STD_FUNCTIONAL_TEST - * Execute geteuid() call - * Execute getpwduid() call - * if the passwd entry is NULL - * break the remaining tests and cleanup - * else if pwent->pw_gid != TEST_RETURN - * print failure message - * else - * print pass message - * else - * print pass message - * call cleanup - * - * USAGE: - * getgid02 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * none - */ - -#include -#include - -#include "test.h" -#include "usctest.h" - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID= "getgid02"; -int TST_TOTAL = 1; -extern int Tst_count; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - int euid; - struct passwd *pwent; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); /* global setup */ - - /* The following loop checks looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(getegid()); - - if (TEST_RETURN < 0) { - tst_brkm(TBROK, cleanup, "This should never happen"); - } - - if (STD_FUNCTIONAL_TEST) { - euid = geteuid(); - - pwent = getpwuid(euid); - - if (pwent == NULL) { - tst_brkm(TBROK, cleanup, "geteuid() returned " - "unexpected value %d", euid); - } else { - if (pwent->pw_gid != TEST_RETURN) { - tst_resm(TFAIL, "getegid() return value" - " %d unexpected - expected %d", - TEST_RETURN, pwent->pw_gid); - } else { - tst_resm(TPASS, "effective group id %d " - "is correct", TEST_RETURN); - } - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - - -/* - * 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; -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup() -{ - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ - TEST_CLEANUP; - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/getgid03.c b/winsup/testsuite/winsup.api/ltp/getgid03.c deleted file mode 100644 index ef0eaea14..000000000 --- a/winsup/testsuite/winsup.api/ltp/getgid03.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * getgid01.c - * - * DESCRIPTION - * Testcase to check the basic functionality of getgid(). - * - * ALGORITHM - * call setup - * loop if that option was specified - * Execute getgid() call using TEST macro - * if not expected value - * break remaining tests and cleanup - * if STD_FUNCTIONAL_TEST - * Execute getuid() call - * Execute getpwduid() call - * if the passwd entry is NULL - * break the remaining tests and cleanup - * else if pwent->pw_gid != TEST_RETURN - * print failure message - * else - * print pass message - * else - * print pass message - * call cleanup - * - * USAGE: - * getgid01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * none - */ - -#include -#include - -#include "test.h" -#include "usctest.h" - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID= "getgid01"; -int TST_TOTAL = 1; -extern int Tst_count; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - int uid; - struct passwd *pwent; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); /* global setup */ - - /* The following loop checks looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(getgid()); - - if (TEST_RETURN < 0) { - tst_brkm(TBROK, cleanup, "This should never happen"); - } - - if (STD_FUNCTIONAL_TEST) { - uid = getuid(); - pwent = getpwuid(uid); - - if (pwent == NULL) { - tst_brkm(TBROK, cleanup, "getuid() returned " - "unexpected value %d", uid); - } else { - if (pwent->pw_gid != TEST_RETURN) { - tst_resm(TFAIL, "getgid() return value " - "%d unexpected - expected %d", - TEST_RETURN, pwent->pw_gid); - } else { - tst_resm(TPASS, "group id %d returned " - "correctly", TEST_RETURN); - } - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - - -/* - * 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; -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup() -{ - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ - TEST_CLEANUP; - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/getgroups01.c b/winsup/testsuite/winsup.api/ltp/getgroups01.c deleted file mode 100644 index db9f942f6..000000000 --- a/winsup/testsuite/winsup.api/ltp/getgroups01.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - -const 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 */ - const 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 deleted file mode 100644 index e05258935..000000000 --- a/winsup/testsuite/winsup.api/ltp/getgroups02.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index ebb6d1724..000000000 --- a/winsup/testsuite/winsup.api/ltp/gethostid01.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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 -#include -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 0e765bfad..000000000 --- a/winsup/testsuite/winsup.api/ltp/gethostname01.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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 -#include -#include - - - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/getpgid01.c b/winsup/testsuite/winsup.api/ltp/getpgid01.c deleted file mode 100644 index 88907f413..000000000 --- a/winsup/testsuite/winsup.api/ltp/getpgid01.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * getpgid01.c - * - * DESCRIPTION - * Testcase to check the basic functionality of getpgid(). - * - * ALGORITHM - * block1: Does getpgid(0), and checks for error. - * block2: Does getpgid(getpid()) and checks for error. - * block3: Does getpgid(getppid()) and checks for error. - * block4: Verifies that getpgid(getpgid(0)) == getpgid(0). - * block5: Does getpgid(1) and checks for error. - * - * USAGE - * getpgid01 - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * Expects that there are no EPERM limitations on getting the - * process group ID from proc 1 (init). - */ - -#include -#include -#include -#include -#include - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -const char *TCID = "getpgid01"; -int TST_TOTAL = 1; -extern int Tst_count; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned by parse_opts */ - - register int pgid_0, pgid_1; - register int my_pid, my_ppid; - int ex_stat, fail = 0; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - } - - setup(); - - /* check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - if ((pgid_0 = fork()) < 0) { - tst_brkm(TBROK, cleanup, "fork() failed"); - } - if (pgid_0 > 0) { /* parent */ - /* - * parent process waits for child to exit, and then - * exits itself. - */ - while ((pgid_0 = wait(&ex_stat)) > 0); - - if (WEXITSTATUS(ex_stat) == 0) { - tst_resm(TINFO, "%s PASSED", TCID); - } else { - tst_resm(TINFO, "%s FAILED", TCID); - } - - /* let the child carry on */ - exit(0); - } - - /* child */ - tst_resm(TINFO, "Enter block 1"); - fail = 0; - if ((pgid_0 = getpgid(0)) < 0) { - perror("getpgid"); - tst_resm(TFAIL, "getpgid(0) failed"); - fail = 1; - } - - if (fail) { - tst_resm(TINFO, "Test block 1: getpgid(0) FAILED"); - } else { - tst_resm(TPASS, "Test block 1: getpgid(0) PASSED"); - } - tst_resm(TINFO, "Exit block 1"); - - tst_resm(TINFO, "Enter block 2"); - fail = 0; - - my_pid = getpid(); - if ((pgid_1 = getpgid(my_pid)) < 0) { - perror("getpgid"); - tst_resm(TFAIL, "getpgid(my_pid=%d) failed", my_pid); - tst_exit(); - } - if (pgid_0 != pgid_1) { - tst_resm(TFAIL, "getpgid(my_pid=%d) != getpgid(0) " - "[%d != %d]", my_pid, pgid_1, pgid_0); - fail = 1; - } - if (fail) { - tst_resm(TINFO, "Test block 2: getpgid(getpid()) " - "FAILED"); - } else { - tst_resm(TPASS, "Test blcok 2: getpgid(getpid()) " - "PASSED"); - } - tst_resm(TINFO, "Exit block 2"); - - tst_resm(TINFO, "Enter block 3"); - fail = 0; - - my_ppid = getppid(); - if ((pgid_1 = getpgid(my_ppid)) < 0) { - perror("getpgid"); - tst_resm(TFAIL, "getpgid(my_ppid=%d) failed", - my_ppid); - tst_exit(); - } - if (pgid_0 != pgid_1) { - tst_resm(TFAIL, "getpgid(my_ppid=%d) != getpgid(0) " - "[%d != %d]", my_ppid, pgid_1, pgid_0); - fail = 1; - } - - if (fail) { - tst_resm(TINFO, "Test block 3: getpgid(getppid()) " - "FAILED"); - } else { - tst_resm(TPASS, "Test block 3: getpgid(getppid()) " - "PASSED"); - } - tst_resm(TINFO, "Exit block 3"); - - tst_resm(TINFO, "Enter block 4"); - fail = 0; - - if ((pgid_1 = getpgid(pgid_0)) < 0) { - perror("getpgid"); - tst_resm(TFAIL, "getpgid(my_pgid=%d) failed", pgid_0); - tst_exit(); - } - if (pgid_0 != pgid_1) { - tst_resm(TFAIL, "getpgid(my_pgid=%d) != getpgid(0) " - "[%d != %d]", pgid_0, pgid_1, pgid_0); - fail = 1; - } - - if (fail) { - tst_resm(TINFO, "Test block 4: getpgid(1) FAILED"); - } else { - tst_resm(TPASS, "Test block 4: getpgid(1) PASSED"); - } - tst_resm(TINFO, "Exit block 4"); -#ifndef __CYGWIN__ -block5: - tst_resm(TINFO, "Enter block 5"); - fail = 0; - - if (getpgid(1) < 0) { - perror("getpgid"); - tst_resm(TFAIL, "getpgid(1) failed"); - fail = 1; - } - - if (fail) { - tst_resm(TINFO, "Test block 5: getpgid(1) FAILED"); - } else { - tst_resm(TPASS, "Test block 5: getpgid(1) PASSED"); - } - tst_resm(TINFO, "Exit block 5"); -#endif - } - cleanup(); -} - -/* - * 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; -} - - -/* - * 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(); -} - diff --git a/winsup/testsuite/winsup.api/ltp/getpgid02.c b/winsup/testsuite/winsup.api/ltp/getpgid02.c deleted file mode 100644 index f6eaec6f6..000000000 --- a/winsup/testsuite/winsup.api/ltp/getpgid02.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * getpgid02.c - * - * DESCRIPTION - * Testcase to check the basic functionality of getpgid(). - * - * ALGORITHM - * test 1: Does getpgid(-99) and expects ESRCH. - * test 2: Searches an unused pid and expects ESRCH. - * - * USAGE: - * getpgid02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * none - */ - -#include -#include -#include -#include -#include - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -const char *TCID = "getpgid01"; -int TST_TOTAL = 2; -extern int Tst_count; - -int pgid_0, pgid_1; -#define BADPID -99 - -int exp_enos[]={ESRCH, 0}; - -struct test_case_t { - int *id; - int error; -} TC[] = { - /* The pid value is negative */ - {&pgid_0, ESRCH}, - - /* The pid value does not match any process */ - {&pgid_1, ESRCH} -}; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - int i; - const char *msg; /* message returned by 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); - } - - setup(); - - /* set up the expected errnos */ - TEST_EXP_ENOS(exp_enos); - - /* check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - - /* loop through the test cases */ - for (i = 0; i < TST_TOTAL; i++) { - - TEST(getpgid(*TC[i].id)); - - if (TEST_RETURN != -1) { - tst_resm(TFAIL, "call succeeded unexpectedly"); - continue; - } - - TEST_ERROR_LOG(TEST_ERRNO); - - if (TEST_ERRNO == TC[i].error) { - tst_resm(TPASS, "expected failure - " - "errno = %d : %s", TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - tst_resm(TFAIL, "unexpected error - %d : %s - " - "expected %d", TEST_ERRNO, - strerror(TEST_ERRNO), TC[i].error); - } - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; - - pgid_0 = BADPID; - - /* - * Find a pid that isn't currently being used. Start - * at 'our pid - 1' and go backwards until we find one. - * In this way, we can be reasonably sure that the pid - * we find won't be reused for a while as new pids are - * allocated counting up to PID_MAX. - */ - for (pgid_1 = getpid() - 1; --pgid_1 > 0; ) { - if (kill(pgid_1, 0) < 0 && errno == ESRCH) { - break; - } - } -} - - -/* - * 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(); -} - diff --git a/winsup/testsuite/winsup.api/ltp/getpgrp01.c b/winsup/testsuite/winsup.api/ltp/getpgrp01.c deleted file mode 100644 index 6997be264..000000000 --- a/winsup/testsuite/winsup.api/ltp/getpgrp01.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index df8197d28..000000000 --- a/winsup/testsuite/winsup.api/ltp/getpid01.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * 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 -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/getpid02.c b/winsup/testsuite/winsup.api/ltp/getpid02.c deleted file mode 100644 index 06d80b38d..000000000 --- a/winsup/testsuite/winsup.api/ltp/getpid02.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: getpid01 - * - * Test Description: - * Verify that getpid() system call gets the process ID of the of the - * calling process. - * - * Expected Result: - * getpid() should return pid of the process on success. - * - * Algorithm: - * 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, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * - * Usage: - * getpid01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -const 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 -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - pid_t proc_id; /* process id of the test process */ - pid_t pid; /* process id of the child process */ - pid_t pproc_id; /* parent process id */ - int status; /* exit status of child process */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Invoke getpid() to get the process id of - * the test process. - */ - TEST(getpid()); - - /* Save the process id returned by getpid() */ - proc_id = TEST_RETURN; - - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* Fork a child now */ - if ((pid = fork()) < 0) { - tst_resm(TFAIL, "fork() failed to create child," - " error=%d", TEST_ERRNO); - } else if (pid == 0) { /* Child process */ - /* Get the parent process id */ - pproc_id = getppid(); - - /* Verify if the two process IDs match */ - if (pproc_id != proc_id) { - exit(1); - } - exit(0); - } else { /* parent process */ - wait(&status); - - /* Check exit status of child */ - if (WEXITSTATUS(status) != 0) { - tst_resm(TFAIL, "getpid() returned " - "invalid pid %d", proc_id); - } else { - tst_resm(TPASS, "Functionality of " - "getpid() successful"); - } - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Setup signal catching function. - */ -void -setup() -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; -} - - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/getppid01.c b/winsup/testsuite/winsup.api/ltp/getppid01.c deleted file mode 100644 index d0e6032c0..000000000 --- a/winsup/testsuite/winsup.api/ltp/getppid01.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/getppid02.c b/winsup/testsuite/winsup.api/ltp/getppid02.c deleted file mode 100644 index 50a72e470..000000000 --- a/winsup/testsuite/winsup.api/ltp/getppid02.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * getppid01.c - * - * DESCRIPTION - * Testcase to check the basic functionality of the getppid() syscall. - * - * USAGE: - * getppid01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include -#include - -const char *TCID = "getppid01"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int ac, char **av) -{ - int pid, ppid; - - int lc; /* loop counter */ - const 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); - } - - setup(); - - /* - * check looping state if -i option is given - */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* - * reset Tst_count in case we are looping. - */ - Tst_count = 0; - - ppid = getpid(); - pid = fork(); - if (pid < 0) { - tst_brkm(TBROK, cleanup, "fork() failed"); - } - - if (pid == 0) { /* child */ - TEST(getppid()); - - if (TEST_RETURN < 0) { - tst_resm(TFAIL, "something is really broken"); - continue; - } - - if (STD_FUNCTIONAL_TEST) { - if (TEST_RETURN != ppid) { - tst_resm(TFAIL, "getppid() failed"); - } else { - tst_resm(TPASS, "return value = " - "parent's pid value"); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - - } else { - wait(NULL); - - /* let the child carry on */ - exit(0); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; -} - - -/* - * 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(); -} - diff --git a/winsup/testsuite/winsup.api/ltp/getuid01.c b/winsup/testsuite/winsup.api/ltp/getuid01.c deleted file mode 100644 index cd3dff769..000000000 --- a/winsup/testsuite/winsup.api/ltp/getuid01.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/getuid02.c b/winsup/testsuite/winsup.api/ltp/getuid02.c deleted file mode 100644 index 966b55290..000000000 --- a/winsup/testsuite/winsup.api/ltp/getuid02.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * getuid02.c - * - * DESCRIPTION - * Testcase to check the basic functionality of the geteuid() system call. - * - * USAGE: - * getuid02 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include -#include - -const char *TCID = "getuid02"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned by parse_opts */ - - struct passwd *pwent; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - } - - setup(); - - /* check looping state if -i option is given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(geteuid()); - - if (TEST_RETURN < 0) { - tst_brkm(TBROK, cleanup, "This should never happen"); - } - - if (STD_FUNCTIONAL_TEST) { - - pwent = getpwuid(TEST_RETURN); - if (pwent == NULL) { - tst_resm(TFAIL, "geteuid() returned unexpected " - "value %d", TEST_RETURN); - } else { - if (pwent->pw_uid != TEST_RETURN) { - tst_resm(TFAIL, "getpwuid() value, %d, " - "does not match geteuid() " - "value, %d", pwent->pw_uid, - TEST_RETURN); - } else { - tst_resm(TPASS, "values from geteuid()" - " and getpwuid() match"); - } - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; -} - - -/* - * 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(); -} - diff --git a/winsup/testsuite/winsup.api/ltp/getuid03.c b/winsup/testsuite/winsup.api/ltp/getuid03.c deleted file mode 100644 index e18c366f4..000000000 --- a/winsup/testsuite/winsup.api/ltp/getuid03.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * getuid01.c - * - * DESCRIPTION - * Testcase to check the basic functionality of the getuid() system call. - * - * USAGE: - * getuid01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ - -#include -#include -#include -#include - -const char *TCID = "getuid01"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned by parse_opts */ - - struct passwd *pwent; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } - - setup(); - - /* check looping state if -i option is given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(getuid()); - - if (TEST_RETURN < 0) { - tst_brkm(TBROK, cleanup, "This should never happen"); - } - - if (STD_FUNCTIONAL_TEST) { - - pwent = getpwuid(TEST_RETURN); - if (pwent == NULL) { - tst_resm(TFAIL, "getuid() returned unexpected " - "value %d", TEST_RETURN); - } else { - if (pwent->pw_uid != TEST_RETURN) { - tst_resm(TFAIL, "getpwuid() value, %d, " - "does not match getuid() " - "value, %d", pwent->pw_uid, - TEST_RETURN); - } else { - tst_resm(TPASS, "values from getuid()" - " and getpwuid() match"); - } - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; -} - - -/* - * 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(); -} - diff --git a/winsup/testsuite/winsup.api/ltp/kill01.c b/winsup/testsuite/winsup.api/ltp/kill01.c deleted file mode 100644 index 042899173..000000000 --- a/winsup/testsuite/winsup.api/ltp/kill01.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * kill01.c - * - * DESCRIPTION - * Test case to check the basic functionality of kill(). - * - * ALGORITHM - * call setup - * loop if the -i option was given - * fork a child - * execute the kill system call - * check the return value - * if return value is -1 - * issue a FAIL message, break remaining tests and cleanup - * if we are doing functional testing - * if the process was terminated with the expected signal. - * issue a PASS message - * otherwise - * issue a FAIL message - * call cleanup - * - * USAGE - * kill01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * This test should be ran as a non-root user. - */ - -#include "test.h" -#include "usctest.h" - -#include -#include -#include - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID= "kill01()"; -int TST_TOTAL = 1; - -extern int Tst_count; - -#define TEST_SIG SIGKILL - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - pid_t pid; - int exno, status, nsig; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - } - - setup(); /* global setup */ - - /* The following loop checks looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - status = 1; - exno = 1; - pid = fork(); - if (pid < 0) { - tst_brkm(TBROK, cleanup, "Fork of child failed"); - } else if (pid == 0) { - pause(); - /*NOTREACHED*/ - exit(exno); - } else { - TEST(kill(pid, TEST_SIG)); - waitpid(pid, &status, 0); - } - - if (TEST_RETURN == -1) { - tst_brkm(TFAIL, cleanup, "%s failed - errno = %d : %s", - TCID, TEST_ERRNO, strerror(TEST_ERRNO)); - /*NOTREACHED*/ - } - - if (STD_FUNCTIONAL_TEST) { - /* - * Check to see if the process was terminated with the - * expected signal. - */ - nsig = WTERMSIG(status); - if (nsig == TEST_SIG) { - tst_resm(TPASS, "received expected signal %d", - nsig); - } else { - tst_resm(TFAIL, "expected signal %d received %d" ,TEST_SIG,nsig); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* Pause if that option was specified */ - TEST_PAUSE; -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup(void) -{ - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ - TEST_CLEANUP; - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/kill02.c b/winsup/testsuite/winsup.api/ltp/kill02.c deleted file mode 100644 index eba47cc6a..000000000 --- a/winsup/testsuite/winsup.api/ltp/kill02.c +++ /dev/null @@ -1,857 +0,0 @@ -/* - * 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 : kill02 Sending a signal to processes with the same process group ID. - - PARENT DOCUMENT : kiltds01 Kill System Call. - - AUTHOR : Dave Baumgartner - - CO-PILOT : Barrie Kletscher - - DATE STARTED : 12/30/85 - - TEST ITEMS - - 1. Sending a signal to pid of zero sends to all processes whose process - group ID is equal to the process group ID as the sender. - - 2. Sending a signal to pid of zero does not send to processes in another process group. - - - OUTPUT SPECIFICATIONS - - PASS : - kiltcs02 1 PASS The signal was sent to all processes in the process group. - kiltcs02 2 PASS The signal was not sent to selective processes that were not in the process group. - - FAIL : - kiltcs02 1 FAIL The signal was not sent to all processes in the process group. - kiltcs02 2 FAIL The signal was sent to a process that was not in the process group. - - BROK : - kiltcs02 # BROK System call XXX failed. Errno:X, Error message:XXX. - kiltcs02 # BROK Setting to catch unexpected signal %d failed. Errno: %d, Error message %s. - kiltcs02 # BROK Setting to ignore signal %d failed. Errno: %d, Error message %s. - - WARN : - kiltcs02 0 WARN Unexpected signal X was caught. - - SPECIAL PROCEDURAL REQUIREMENTS - - The program must be linked with tst_res.o. - - DETAILED DESCRIPTION - - **Setup** - Set up unexpected signal handling. - Set up one pipe for each process to be created with no blocking for read. - - **MAIN** - If setup fails exit. - Fork 2 children(1 & 2). - Wait for set up complete messages from the 1st and 2nd child. - Send the signal SIGUSR1 with pid equal to zero. - Sleep a reasonable amount of time so that each child has been swapped in - to process the signal. - Now decide the outcome of the test items by reading from each pipe to find - out if the child was interrupted by the signal and wrote to it. - Remove the second child. - Tell the first child it is time to remove it's child B because the decisions have been made. - Exit. - - **First Child** - Set to catch SIGUSR1 with an int_rout1. - Set up to handle the message from the parent to remove child B. - Fork two children(A & B). - Wait for set up complete messages from child A & child B. - Send a set up complete message to the parent. - Pause until the signal SIGUSR1 comes in from the parent. - Pause until the parent says it is time to remove the child. - Exit. - - **Second Child** - Set to catch SIGUSR1 with an int_rout2. - Set the process group to be something different than the parents. - Send a set up complete message to the parent. - Pause until killed by parent because this child shouldn't receive signal SIGUSR1. - - **Child A** - Set to catch SIGUSR1 with an int_routA. - Send a set up complete message to the parent(First Child). - Pause until the signal SIGUSR1 comes in from the parent. - Exit. - - **Child B** - Set to catch SIGUSR1 with an int_routB. - Set the process group to be something different than the parents(First Child's). - Send a set up complete message to the parent. - Pause until killed by parent because this child shouldn't receive signal SIGUSR1. - - **usr1_rout-Used by all children** - Write to the appropriate pipe that the signal SIGUSR1 was caught. - - **usr2_rout** - Remove child B. - -******************************************************************************/ -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -#define MAXMESG 150 /*The maximum message that can be created. */ -#define CHAR_SET_FAILED "0" /*Set up failing status transferred through the pipe. */ -#define CHAR_SET_PASSED "1" /*Set up passing status transferred through the pipe. */ -#define SIG_CAUGHT "2" /*Indicates that the signal SIGUSR1 was caught. */ -#define SIG_RECEIVED 1 /*Integer value that indicates that the signal SIGUSR1 */ - /*was caught. */ -#define SIG_NOT_RECD 0 /*Integer value that indicates that the signal SIGUSR1 */ - /*was caught. */ -#define INT_SET_FAILED 0 /*Set up failing status transferred through the pipe. */ -#define INT_SET_PASSED 1 /*Set up passing status transferred through the pipe. */ -#define SLEEP_TIME 10 /*Amount of time the children get to catch the signal */ -#define TRUE 40 /*Child exits with this if execution was as */ - /*expected. */ -#define FALSE 50 /*Child exits with this if it timed out waiting for the */ - /*parents signal. */ -#define TIMEOUT 60 /*Amount of time given in alarm calls. */ -#define CHILD_EXIT(VAR) ((VAR >> 8) & 0377) /*Exit value from the child. */ -#define CHILD_SIG(VAR) (VAR & 0377) /*Signal value from the termination of child. */ - /*from the parent. */ -#define SYS_FAIL "The system call %s failed. Errno: %d, Error message: %s." - -int pid1; /*Return value from 1st fork. Global so that it can be */ - /*used in interrupt handling routines. */ -int pid2; /*Return value from 2nd fork. Global so that it can be */ - /*used in interrupt handling routines. */ -int pidA; /*Return value from 1st fork in child 1. Global so that it */ - /*can be used in interrupt handling routines. */ -int pidB; /*Return value from 2nd fork in child 1. Global so that it */ - /*can be used in interrupt handling routines. */ -extern int errno; /*Error number returned by a system call. */ -int pipe1_fd[2]; /*Pipe file descriptors used for communication */ - /*between child 1 and the 1st parent. */ -int pipe2_fd[2]; /*Pipe file descriptors used for communication */ - /*between child 2 and the 1st parent. */ -int pipeA_fd[2]; /*Pipe file descriptors used for communication */ - /*between child A and the 1st parent. */ -int pipeB_fd[2]; /*Pipe file descriptors used for communication */ - /*between child B and the 1st parent. */ -char pipe_buf[10]; /*Pipe buffer. */ -char buf_tmp1[2],buf_tmp2[2]; /*Temp hold for info read into pipe_buf. */ -int read1_stat = 0; /*Number of characters read from pipe 1. */ -int read2_stat = 0; /*Number of characters read from pipe 2. */ -int readA_stat = 0; /*Number of characters read from pipe A. */ -int readB_stat = 0; /*Number of characters read from pipe B. */ -int alarm_flag = FALSE; /*This flag indicates an alarm time out. */ -char who_am_i = '0'; /*This indicates which process is which when using */ - /*interrupt routine usr1_rout. */ - -void notify_timeout(); /*Signal handler that the parent enters if it times out */ - /*waiting for the child to indicate its set up status. */ -void parent_rout(); /*This is the parents routine. */ -void child1_rout(); /*This is child 1's routine. */ -void child2_rout(); /*This is child 2's routine. */ -void childA_rout(); /*This is child A's routine. */ -void childB_rout(); /*This is child B's routine. */ -void usr1_rout(); /*This routine is used by all children to indicate that */ - /*they have caught signal SIGUSR1. */ -void par_kill(); /*This routine is called by the original parent to */ - /*remove child 2 and to indicate to child 1 to */ - /*remove its children. */ -void chld1_kill(); /*This routine is used by child 1 to remove itself and */ - /*its children A and B. */ - -void setup(); -void cleanup(void) __attribute__((noreturn)); - -const char *TCID="kill02"; /* 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; /* var. used to turn off tst_res buffering */ - -int exp_enos[]={0}; /* Array of expected errnos */ - -/*********************************************************************** - * MAIN - ***********************************************************************/ -int -main(int ac, char **av) -{ - char mesg[MAXMESG]; /* Holds messages to pass to tst_res. */ - - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - Tst_nobuf=1; - - /*************************************************************** - * parse standard options, and exit if there is an error - * the -t and -f options not support yet. - ***************************************************************/ - 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; - - if ((pid1 = fork()) > 0) - { - /* - * This is the parent, fork again to create child 2. - */ - if ((pid2 = fork()) > 0) { - /* - * This is the parent. - */ - (void) parent_rout(); - } - else if (pid2 == 0) { - /* - * This is child 2. - */ - (void) child2_rout(); - } - else { - /* - * The second fork failed kill the first child. - */ - if (kill(pid1,SIGKILL) == -1 && errno != ESRCH) { - tst_resm(TWARN,"Child process may not have been killed."); - } - (void) sprintf(mesg,SYS_FAIL,"fork",errno,strerror(errno)); - tst_brkm(TBROK,cleanup,mesg); - } - - } - else if (pid1 == 0) { - /* - * This is child 1. - */ - (void) child1_rout(); - } - else { - /* - * Fork failed. - */ - (void) sprintf(mesg,SYS_FAIL,"fork",errno,strerror(errno)); - tst_brkm(TBROK,cleanup,mesg); - } - } - - cleanup(); - - return 0; -} /* END OF MAIN.*/ - -/****************************************************************************** - * This is the parents routine. The parent waits for the children 1 and 2 to - * get set up. Then sends the signal and checks the outcome. - *********************************************************************************/ -void parent_rout() -{ - char mesg[MAXMESG]; /*Used to buffer messages for tst_resm. */ - - /* - * Set to catch the alarm signal SIGALRM. - */ - if (signal(SIGALRM,notify_timeout) == SIG_ERR) { - (void) par_kill(); - tst_brkm(TBROK, NULL, - "Could not set to catch the parents time out alarm."); - tst_exit(); - } - - /* - * Setting to catch the timeout alarm worked now let the children start up. - * Set an alarm which causes a time out on the read pipe loop. - * The children will notify the parent that set up is complete - * and the pass/fail status of set up. - */ - (void) alarm(TIMEOUT); - - while ((read(pipe1_fd[0],pipe_buf,1) != 1) && (alarm_flag == FALSE)) - /*EMPTY*/; - strncpy(buf_tmp1,pipe_buf,1); - (void) alarm(TIMEOUT); - - while ((read(pipe2_fd[0],pipe_buf,1) != 1) && (alarm_flag == FALSE)) - /*EMPTY*/; - (void) alarm(0); /*Reset the alarm clock.*/ - strncpy(buf_tmp2,pipe_buf,1); - - /* - * Check the alarm flag. - */ - if (alarm_flag == TRUE) { - tst_brkm(TBROK,NULL,"The set up of the children failed by timing out."); - (void) par_kill(); - cleanup(); - } - - /* - * Check to see if either child failed in the set up. - */ - if ( (strncmp(buf_tmp1,CHAR_SET_FAILED,1) == 0) || - (strncmp(buf_tmp2,CHAR_SET_FAILED,1) == 0)) { - /* - * Problems were encountered in the set up of one of the children. - * The error message has been displayed by the child. - */ - (void) par_kill(); - cleanup(); - } - - /* - * Setup passed, now send SIGUSR1 to process id of zero. - */ - TEST( kill(0,SIGUSR1) ); - - if ( TEST_RETURN == -1) - { - (void) sprintf(mesg,SYS_FAIL,"kill",errno,strerror(errno)); - tst_brkm(TBROK,NULL,mesg); - (void) par_kill(); - cleanup(); - } - - /* - * Sleep for a while to allow the children to get a chance to - * catch the signal. - */ - (void) sleep(SLEEP_TIME); - - /* - * The signal was sent above and time has run out for child response, - * check the outcomes. - */ - read1_stat = read(pipe1_fd[0],pipe_buf,1); - if (read1_stat == -1 && errno == EAGAIN) read1_stat = 0; - read2_stat = read(pipe2_fd[0],pipe_buf,1); - if (read2_stat == -1 && errno == EAGAIN) read2_stat = 0; - readA_stat = read(pipeA_fd[0],pipe_buf,1); - if (readA_stat == -1 && errno == EAGAIN) readA_stat = 0; - readB_stat = read(pipeB_fd[0],pipe_buf,1); - if (readB_stat == -1 && errno == EAGAIN) readB_stat = 0; - - if (read1_stat == -1 || read2_stat == -1 || - readA_stat == -1 || readB_stat == -1) { - /* - * The read system call failed. - */ - (void) sprintf(mesg,SYS_FAIL,"read",errno,strerror(errno)); - tst_brkm(TBROK,NULL,mesg); - (void) par_kill(); - cleanup(); - } - - /* - * Check the processes that were supposed to get the signal. - */ - if (read1_stat == SIG_RECEIVED) { - if (readA_stat == SIG_RECEIVED) { - /* - * Both processes, 1 and A, that were supposed to receive - * the signal did receive the signal. - */ - if ( STD_FUNCTIONAL_TEST ) - tst_resm(TPASS, - "The signal was sent to all processes in the process group."); - else - Tst_count++; - } - else { /*Process A didn't receive the signal.*/ - tst_resm(TFAIL,"Process A did not receive the signal."); - } - - } - else { /*Process 1 didn't receive the signal.*/ - tst_resm(TFAIL,"Process 1 did not receive the signal."); - } - - /* - * Check the processes that were not supposed to get the signal. - */ - if (read2_stat == SIG_NOT_RECD) { - if (readB_stat == SIG_NOT_RECD) { - /* - * Both processes, 2 and B did not receive the signal. - */ - if ( STD_FUNCTIONAL_TEST ) - tst_resm(TPASS, - "The signal was not sent to selective processes that were not in the process group."); - else - Tst_count++; - } - else { /*Process B received the signal.*/ - tst_resm(TFAIL,"Process B received the signal."); - } - - } - - else /*Process 2 received the signal.*/ - { - tst_resm(TFAIL,"Process 2 received the signal."); - } - - (void) par_kill(); - return; -} /*End of parent_rout*/ - -/******************************************************************************* - * This is child 1's routine. It creates children A & B, checks their set up, - * reports to the parent set up pass/fail info., then waits for - * the parents signal. - ******************************************************************************/ -void child1_rout() -{ - char mesg[MAXMESG]; /*Used to buffer messages for tst_resm. */ - who_am_i = '1'; - - /* - * Set to catch the SIGUSR1 with int1_rout. - */ - if (signal(SIGUSR1,usr1_rout) == SIG_ERR) - { - tst_brkm(TBROK,NULL,"Could not set to catch the childrens signal."); - (void) write(pipe1_fd[1],CHAR_SET_FAILED,1); - exit(0); - } - - /* - * Create children A & B. - */ - if ((pidA = fork()) > 0) { - /* - * This is the parent(child1), fork again to create child B. - */ - if ((pidB = fork()) == 0) { - /* This is child B. */ - (void) childB_rout(); - } - - else if (pidB == -1) { - /* - * The fork of child B failed kill child A. - */ - if (kill(pidA,SIGKILL) == -1) - tst_resm(TWARN,"Child process may not have been killed."); - (void) sprintf(mesg,SYS_FAIL,"fork",errno,strerror(errno)); - tst_brkm(TBROK,NULL,mesg); - (void) write(pipe2_fd[1],CHAR_SET_FAILED,1); - exit(0); - } - } - - else if (pidA == 0) { - /* This is child A. */ - (void) childA_rout(); - - } - - else if (pidA == -1) { - /* - * The fork of child A failed. - */ - (void) sprintf(mesg,SYS_FAIL,"fork",errno,strerror(errno)); - tst_brkm(TBROK,NULL,mesg); - (void) write(pipe1_fd[1],CHAR_SET_FAILED,1); - exit(0); - } - - /* - * Set to catch the SIGUSR2 with chld1_kill. - */ - if (signal(SIGUSR2,chld1_kill) == SIG_ERR) { - tst_brkm(TBROK,NULL,"Could not set to catch the parents signal."); - (void) write(pipe1_fd[1],CHAR_SET_FAILED,1); - (void) chld1_kill(); - exit(0); - } - - /* - * Set to catch the alarm signal SIGALRM. - */ - if (signal(SIGALRM,notify_timeout) == SIG_ERR) { - tst_brkm(TBROK,NULL,"Could not set to catch the childs time out alarm."); - (void) write(pipe1_fd[1],CHAR_SET_FAILED,1); - (void) chld1_kill(); - exit(0); - } - - /* - * Setting to catch the signals worked now let the children start up. - * Set an alarm which causes a time out on the pipe read loop. - * The children A & B will notify the parent(child1) that set up is complete - * and the pass/fail status of set up. - */ - (void) alarm(TIMEOUT-40); - - while ((read(pipeA_fd[0],pipe_buf,1) != 1) && (alarm_flag == FALSE)) - /*EMPTY*/; - (void) alarm(TIMEOUT-40); - - while ((read(pipeB_fd[0],pipe_buf,1) != 1) && (alarm_flag == FALSE)) - /*EMPTY*/; - (void) alarm(0); /*Reset the alarm clock.*/ - - /* - * Check the alarm flag. - */ - if (alarm_flag == TRUE) { - tst_brkm(TBROK,NULL,"The set up of the children failed by timing out."); - (void) chld1_kill(); - (void) write(pipe1_fd[1],CHAR_SET_FAILED,1); - exit(0); - } - - /* - * Send a set up complete message to the parent. - */ - (void) write(pipe1_fd[1],CHAR_SET_PASSED,1); - - /* - * Pause until the signal SIGUSR1 or SIGUSR2 is sent from the parent. - */ - (void) pause(); - - /* - * Pause until signal SIGUSR2 is sent from the parent. - * This pause will only be executed if SIGUSR2 has not been received yet. - */ - while (1) { - sleep(1); - } - -} /*End of child1_rout*/ - -/******************************************************************************* - * This is the routine for child 2, which should not receive the parents signal. - ******************************************************************************/ -void child2_rout() -{ - who_am_i = '2'; - - /* - * Set the process group of this process to be different - * than the other processes. - */ - (void) setpgrp(); - - /* - * Set to catch the SIGUSR1 with usr1_rout. - */ - if (signal(SIGUSR1,usr1_rout) == SIG_ERR) { - tst_brkm(TBROK,cleanup,"Could not set to catch the parents signal."); - (void) write(pipe2_fd[1],CHAR_SET_FAILED,1); - exit(0); - } - - /* Send a set up complete message to parent.*/ - (void) write(pipe2_fd[1],CHAR_SET_PASSED,1); - - /* - * Pause until killed by the parent or SIGUSR1 is received. - */ - (void) pause(); -} - - -/******************************************************************************* - * This is the routine for child A, which should receive the parents signal. - ******************************************************************************/ -void childA_rout() -{ - who_am_i = 'A'; - - /* Send a set up complete message to parent.*/ - write(pipeA_fd[1],CHAR_SET_PASSED,1); - - /* - * Pause until killed by the parent or SIGUSR1 is received. - */ - (void) pause(); - - exit(0); -} /*End of childA_rout*/ - -/******************************************************************************* - * This is the routine for child B, which should not receive the parents signal. - ******************************************************************************/ -void childB_rout() -{ - who_am_i = 'B'; - - /* - * Set the process group of this process to be different - * than the other processes. - */ - (void) setpgrp(); - - /* Send a set up complete message to parent(child 1).*/ - write(pipeB_fd[1],CHAR_SET_PASSED,1); - - /* - * Pause until killed by the parent(child 1) or SIGUSR1 is received. - */ - (void) pause(); - - exit(0); -} - -/******************************************************************************* - * This routine sets up the interprocess communication pipes, signal handling, - * and process group information. - ******************************************************************************/ -void -setup() -{ - int errno_buf = 0; /*indicates the errno if pipe set up fails. */ - int err_flag = FALSE; /*Indicates if an error has occurred in pipe set up. */ - char mesg[MAXMESG]; /*Used to buffer messages for tst_res. */ - - /* - * Set the process group ID to be equal between the parent and children. - */ - (void) setpgrp(); - - /* - * Set to catch unexpected signals. - * SIGCLD is set to be ignored because we do not wait for termination status. - * SIGUSR1 is set to be ignored because this is the signal we are using for - * the test and we are not concerned with the parent getting it. - */ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - if (signal(SIGUSR1,SIG_IGN) == SIG_ERR) { - (void) sprintf(mesg, - "Setting to ignore signal SIGCLD failed. Errno: %d, Error message %s.", - errno,strerror(errno)); - tst_brkm(TBROK,NULL,mesg); - tst_exit(); - } - - if (signal(SIGCLD,SIG_IGN) == SIG_ERR) { - (void) sprintf(mesg, - "Setting to ignore signal SIGCLD failed. Errno: %d, Error message %s.", - errno,strerror(errno)); - tst_brkm(TBROK,NULL,mesg); - tst_exit(); - } - - /* Indicate which errnos are expected */ - TEST_EXP_ENOS(exp_enos); - - /* Pause if that option was specified */ - TEST_PAUSE; - - - /* - * Set up pipe1, pipe2, pipeA, and pipeB. - */ - if ((pipe(pipe1_fd) == -1) || (fcntl(pipe1_fd[0],F_SETFL,O_NDELAY) == -1)) - { - errno_buf = errno; - err_flag = TRUE; - } - - if ((pipe(pipe2_fd) == -1) || (fcntl(pipe2_fd[0],F_SETFL,O_NDELAY) == -1)) - { - errno_buf = errno; - err_flag = TRUE; - } - - if ((pipe(pipeA_fd) == -1) || (fcntl(pipeA_fd[0],F_SETFL,O_NDELAY) == -1)) - { - errno_buf = errno; - err_flag = TRUE; - } - - if ((pipe(pipeB_fd) == -1) || (fcntl(pipeB_fd[0],F_SETFL,O_NDELAY) == -1)) - { - errno_buf = errno; - err_flag = TRUE; - } - - /* - * Check for errors. - */ - if (err_flag == TRUE) - { - (void) sprintf(mesg,SYS_FAIL,"pipe",errno_buf,strerror(errno_buf)); - tst_brkm(TBROK, NULL, mesg); - tst_exit(); - } - return; - -} - -/*********************************************************** - * This routine indicates that the process caught SIGUSR1. - **********************************************************/ -void usr1_rout() -{ - char mesg[MAXMESG]; /*Used to buffer messages for tst_res. */ - - switch (who_am_i) - { - case '1': if (write(pipe1_fd[1],SIG_CAUGHT,1) == -1) - tst_resm(TWARN,"Writing signal catching status failed in child 1."); - break; - case '2': if (write(pipe2_fd[1],SIG_CAUGHT,1) == -1) - tst_resm(TWARN,"Writing signal catching status failed in child 2."); - break; - case 'A': if (write(pipeA_fd[1],SIG_CAUGHT,1) == -1) - tst_resm(TWARN,"Writing signal catching status failed in child A."); - break; - case 'B': if (write(pipeB_fd[1],SIG_CAUGHT,1) == -1) - tst_resm(TWARN,"Writing signal catching status failed in child B."); - break; - default: - sprintf(mesg,"Unexpected value %d for who_am_i in usr1_rout().",who_am_i); - tst_resm(TWARN,mesg); - break; - } - -} /*End of usr1_rout*/ - - -/*********************************************************** - * This routine handles the timeout alarm in the parent, - * which occurs when the child fails to notify the parent - * the status of set up. - **********************************************************/ -void notify_timeout() -{ - alarm_flag = TRUE; - -} /*End of notify_timeout*/ - -/*********************************************************** - * This routine handles the procedure for removing the - * children forked off during this test. - **********************************************************/ -void par_kill() -{ - char mesg[MAXMESG]; /*Used to buffer messages for tst_res. */ - /* - * Indicate to child1 that it can remove it's children and itself now. - */ - if (kill(pid1,SIGUSR2) == -1 && errno != ESRCH) - { - (void) sprintf(mesg,SYS_FAIL,"kill",errno,strerror(errno)); - tst_resm(TWARN,mesg); - tst_resm(TWARN,"Child 1 and it's children may still be alive."); - } - - /* - * Remove child 2. - */ - if (kill(pid2,SIGKILL) == -1 && errno != ESRCH) - tst_resm(TWARN,"Child2 may still be alive."); - - return; - -} /*End of par_kill*/ - - -/********************************************************************* - * This routine is executed by child 1 when the parent tells it to - * remove it's children and itself. - ********************************************************************/ -void chld1_kill() -{ - char mesg[MAXMESG]; /*Used to buffer messages for tst_resm. */ - - /* - * Remove children A & B. - */ - if (kill(pidA,SIGKILL) == -1 && errno != ESRCH) - { - (void) sprintf(mesg, - "The system call kill failed. Child 1's(A) child may still be alive. Errno: %d, Error message %s.", - errno,strerror(errno)); - tst_resm(TWARN,mesg); - } - if (kill(pidB,SIGKILL) == -1 && errno != ESRCH) - { - (void) sprintf(mesg, - "The system call kill failed. Child 1's(B) child may still be alive. Errno: %d, Error message %s.", - errno,strerror(errno)); - tst_resm(TWARN,mesg); - } - - exit(0); - -} /*End of chld1_kill*/ - -/*************************************************************** - * 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/kill03.c b/winsup/testsuite/winsup.api/ltp/kill03.c deleted file mode 100644 index 1de727fd7..000000000 --- a/winsup/testsuite/winsup.api/ltp/kill03.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * kill03.c - * - * DESCRIPTION - * Test case to check that kill fails when given an invalid signal. - * - * ALGORITHM - * call setup - * loop if the -i option was given - * fork a child - * execute the kill system call with an invalid signal - * check the return value - * if return value is not -1 - * issue a FAIL message, break remaining tests and cleanup - * if we are doing functional testing - * if the errno was set to 22 (invalid argument). - * issue a PASS message - * otherwise - * issue a FAIL message - * call cleanup - * - * USAGE - * kill03 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * none - */ - -#include "test.h" -#include "usctest.h" - -#include -#include -#include - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID= "kill03()"; -int TST_TOTAL = 1; - -extern int Tst_count; - -int exp_enos[] = {EINVAL, 0}; - -#define TEST_SIG 2000 - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - pid_t pid; - int exno, 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); - } - - setup(); /* global setup */ - - TEST_EXP_ENOS(exp_enos); - - /* The following loop checks looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - status = 1; - exno = 1; - pid = fork(); - if (pid < 0) { - tst_brkm(TBROK, cleanup, "Fork of child failed"); - } else if (pid == 0) { - pause(); - /*NOTREACHED*/ - exit(exno); - } else { - TEST(kill(pid, TEST_SIG)); - kill(pid, SIGKILL); - waitpid(pid, &status, 0); - } - - if (TEST_RETURN != -1) { - tst_brkm(TFAIL, cleanup, "%s failed - errno = %d : %s " - "Expected a return value of -1 got %d", - TCID, TEST_ERRNO, strerror(TEST_ERRNO)), - TEST_RETURN; - /*NOTREACHED*/ - } - - if (STD_FUNCTIONAL_TEST) { - /* - * Check to see if the errno was set to the expected - * value of 22 : EINVAL. - */ - TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO == EINVAL) { - tst_resm(TPASS, "errno set to %d : %s, as " - "expected", TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - tst_resm(TFAIL, "errno set to %d : %s expected " - "%d : %s", TEST_ERRNO, - strerror(TEST_ERRNO), 22, strerror(22)); - } - } - } - cleanup(); - - /*NOTREACHED*/ -} - - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* Pause if that option was specified */ - TEST_PAUSE; -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup(void) -{ - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ - TEST_CLEANUP; - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/kill04.c b/winsup/testsuite/winsup.api/ltp/kill04.c deleted file mode 100644 index a7b3274c3..000000000 --- a/winsup/testsuite/winsup.api/ltp/kill04.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * kill04.c - * - * DESCRIPTION - * Test case to check that kill() fails when passed a non-existant pid. - * - * ALGORITHM - * call setup - * loop if the -i option was given - * fork a child - * execute the kill system call with a non-existant PID - * check the return value - * if return value is not -1 - * issue a FAIL message, break remaining tests and cleanup - * if we are doing functional testing - * if the errno was set to 3 (No such proccess) - * issue a PASS message - * otherwise - * issue a FAIL message - * call cleanup - * - * USAGE - * kill04 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * This test should be run by a non-root user - */ - -#include "test.h" -#include "usctest.h" - -#include -#include -#include - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID= "kill04()"; -int TST_TOTAL = 1; - -extern int Tst_count; - -int exp_enos[] = {ESRCH, 0}; - -#define TEST_SIG SIGKILL - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - pid_t pid, fake_pid; - int exno, status, fake_status, nsig; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - } - - setup(); /* global setup */ - - TEST_EXP_ENOS(exp_enos); - - /* The following loop checks looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - status = 1; - exno = 1; - pid = fork(); - if (pid < 0) { - tst_brkm(TBROK, cleanup, "Fork failed"); - } else if (pid == 0) { - pause(); - /*NOTREACHED*/ - exit(exno); - } else { - fake_pid = fork(); - if (fake_pid < 0) { - tst_brkm(TBROK, cleanup, "Second fork failed"); - } else if (fake_pid == 0) { - pause(); - /*NOTREACHED*/ - exit(exno); - } - kill(fake_pid, TEST_SIG); - waitpid(fake_pid, &fake_status, 0); - TEST(kill(fake_pid, TEST_SIG)); - kill(pid, TEST_SIG); - waitpid(pid, &status, 0); - } - - if (TEST_RETURN != -1) { - tst_brkm(TFAIL, cleanup, "%s failed - errno = %d : %s " - "Expected a return value of -1 got %d", - TCID, TEST_ERRNO, strerror(TEST_ERRNO)), - TEST_RETURN; - /*NOTREACHED*/ - } - - if (STD_FUNCTIONAL_TEST) { - /* - * Check to see if the errno was set to the expected - * value of 3 : ESRCH - */ - nsig = WTERMSIG(status); - TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO == ESRCH) { - tst_resm(TPASS, "errno set to %d : %s, as " - "expected", TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - tst_resm(TFAIL, "errno set to %d : %s expected " - "%d : %s", TEST_ERRNO, - strerror(TEST_ERRNO), 3, strerror(3)); - } - } - } - cleanup(); - - /*NOTREACHED*/ -} - - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* Pause if that option was specified */ - TEST_PAUSE; -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup(void) -{ - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ - TEST_CLEANUP; - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/kill09.c b/winsup/testsuite/winsup.api/ltp/kill09.c deleted file mode 100644 index 3b4c24fb5..000000000 --- a/winsup/testsuite/winsup.api/ltp/kill09.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * 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 -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); -void alarm_handler(int sig); - - - - -const 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 */ - const 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 deleted file mode 100644 index 84c53c23c..000000000 --- a/winsup/testsuite/winsup.api/ltp/link02.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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 deleted file mode 100644 index 38c16af72..000000000 --- a/winsup/testsuite/winsup.api/ltp/link03.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void help(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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 deleted file mode 100644 index b3453b5d0..000000000 --- a/winsup/testsuite/winsup.api/ltp/link04.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include /* for PATH_MAX */ -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - -extern char *get_high_address(); - -const 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 { - const char *file1; - const char *desc1; - const char *file2; - const 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 */ - const char *msg; /* message returned from parse_opts */ - const char *fname1, *fname2; - const 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 deleted file mode 100644 index 9387c25a8..000000000 --- a/winsup/testsuite/winsup.api/ltp/link05.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); -void help(); - - - -const 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 */ - const 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 deleted file mode 100644 index 22d0c6c39..000000000 --- a/winsup/testsuite/winsup.api/ltp/lseek01.c +++ /dev/null @@ -1,255 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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 deleted file mode 100644 index 04fa3f10f..000000000 --- a/winsup/testsuite/winsup.api/ltp/lseek02.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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/lseek03.c b/winsup/testsuite/winsup.api/ltp/lseek03.c deleted file mode 100644 index 51c303d85..000000000 --- a/winsup/testsuite/winsup.api/ltp/lseek03.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * 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 : lseek03 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Negative test for lseek(2) whence - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 2 - * - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); -void rec_sigsys(int); - -const char *TCID="lseek03"; /* Test program identifier. */ -int TST_TOTAL=3; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -char fname[255]; -int fd; -int Rec_sigsys = 0; - -int Whences[] = { 4, -1, 7 }; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - unsigned ind; - int whence; - - TST_TOTAL=sizeof(Whences)/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(); - - - signal(SIGSYS, rec_sigsys); - - /*************************************************************** - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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 deleted file mode 100644 index 8867086bd..000000000 --- a/winsup/testsuite/winsup.api/ltp/lseek05.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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/lseek06.c b/winsup/testsuite/winsup.api/ltp/lseek06.c deleted file mode 100644 index f62c3422c..000000000 --- a/winsup/testsuite/winsup.api/ltp/lseek06.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: lseek01 - * - * Test Description: - * Verify that, lseek() call succeeds to set the file pointer position - * to less than or equal to the file size, when a file is opened for - * read or write. - * - * Expected Result: - * lseek() should return the offset from the beginning of the file measured - * in bytes. Also check if able to read valid data from this location. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * Create temporary directory. - * - * 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, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * lseek01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define OFFSET 4 -#define TEMP_FILE "tmp_file" -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH - -const char *TCID="lseek01"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -int fildes; /* file handle for temp file */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - char read_buf[1]; /* data read from temp. file */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Invoke lseek(2) to move the read/write file - * pointer/handle by OFFSET bytes. - */ - TEST(lseek(fildes, OFFSET, SEEK_SET)); - - /* check return code of lseek(2) */ - if (TEST_RETURN == (off_t)-1) { - tst_resm(TFAIL, "lseek on (%s) Failed, errno=%d : %s", - TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Check if the return value from lseek(2) - * is equal to the specified OFFSET value. - */ - if (TEST_RETURN != OFFSET) { - tst_resm(TFAIL, "lseek() returned incorrect " - "value %d, expected %d", - TEST_RETURN, OFFSET); - continue; - } - /* - * The return value is good, now check data. - * Read the data byte from this location. - */ - if (read(fildes, &read_buf, sizeof(read_buf)) < 0) { - tst_brkm(TFAIL, cleanup, "read() failed " - "on %s, error=%d", TEMP_FILE, errno); - } else { - /* - * Check if read byte is the expected character. - * For pos 4 ---> 'e' - */ - if (read_buf[0] != 'e') { - tst_resm(TFAIL, "Incorrect data read " - "from file %s", TEMP_FILE); - } else { - tst_resm(TPASS, "Functionality " - "of lseek() on %s " - "successful", TEMP_FILE); - } - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and write some - * data into it. - */ -void -setup() -{ - char write_buf[BUFSIZ]; /* buffer to hold data */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Get the data to be written to temporary file */ - strcpy(write_buf, "abcdefg"); - - /* Creat/open a temporary file under above directory */ - if ((fildes = open(TEMP_FILE, O_RDWR | O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s", - TEMP_FILE, FILE_MODE, errno, strerror(errno)); - } - - /* Write data into temporary file */ - if(write(fildes, write_buf, strlen(write_buf)) != (int)strlen(write_buf)) { - tst_brkm(TBROK, cleanup, "write(2) on %s Failed, errno=%d : %s", - TEMP_FILE, errno, strerror(errno)); - } -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Close the temporary file created */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, NULL, "close(%s) Failed, errno=%d : %s:", - TEMP_FILE, errno, strerror(errno)); - } - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/lseek07.c b/winsup/testsuite/winsup.api/ltp/lseek07.c deleted file mode 100644 index c5a27b5b3..000000000 --- a/winsup/testsuite/winsup.api/ltp/lseek07.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: lseek02 - * - * Test Description: - * Verify that, lseek() call succeeds to set the file pointer position - * to more than the file size, when a file is opened for reading/writing. - * - * Expected Result: - * lseek() should return n+1, where n is the size of the file. - * Also when some data is written into this file it should start - * from that offset. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * Create temporary directory. - * - * 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, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * lseek02 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMP_FILE "tmp_file" -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH - -const 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 fildes; /* file handle for temp file */ -size_t file_size; /* size of temporary file */ -char write_buf1[BUFSIZ]; /* buffer to hold data */ -char write_buf2[BUFSIZ]; /* buffer to hold data */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - char read_buf[BUFSIZ]; /* data read from temp. file */ - off_t offset; /* byte position in temporary file */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* Set the offset position */ - offset = file_size + (lc * strlen(write_buf2)); - - /* - * Invoke lseek(2) to move the write file - * pointer/handle by the specified offset value. - */ - TEST(lseek(fildes, offset, SEEK_SET)); - - /* check return code of lseek(2) */ - if (TEST_RETURN == (off_t)-1) { - tst_resm(TFAIL, "lseek on (%s) Failed, errno=%d : %s", - TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Check if the return value from lseek(2) - * is equal to the specified offset value. - */ - if (TEST_RETURN != offset) { - tst_resm(TFAIL, "lseek() returned " - "incorrect value %d, expected " - "%d", TEST_RETURN, offset); - continue; - } - /* - * The return value is okay, now write some data at - * the current offset position. - */ - if (write(fildes, write_buf2, strlen(write_buf2)) != - (int)strlen(write_buf2)) { - tst_brkm(TFAIL, cleanup, "write() failed to " - "write additional data, error = %d", - errno); - } - - /* - * Now close the file and open it again - * and read all of the data. - */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, cleanup, "close() on %s Failed," - " errno = %d", TEMP_FILE, errno); - } - - /* Open the file again in read/write mode */ - if ((fildes = open(TEMP_FILE, O_RDWR)) < 0) { - tst_brkm(TFAIL, cleanup, "Could not open the " - "%s readonly, error = %d", - TEMP_FILE, errno); - } - - /* - * Now read all of the data. The size should be the - * offset + strlen(write_buf2). - */ - if (read(fildes, &read_buf, (offset + - strlen(write_buf2))) < 0) { - tst_brkm(TFAIL, cleanup, "read() failed on %s, " - "error=%d", TEMP_FILE, errno); - } else { - /* - * Check data read is the complete data and not - * the only portion written. - */ - if ((strncmp(read_buf, write_buf1, - strlen(write_buf1))) != 0) { - tst_brkm(TFAIL, cleanup, - "Incorrect data read #1 from " - "file %s", TEMP_FILE); - } - if ((strncmp(&read_buf[offset], write_buf2, - strlen(write_buf2))) != 0) { - tst_brkm(TFAIL, cleanup, - "Incorrect data read #2 from " - "file %s", TEMP_FILE); - } - tst_resm(TPASS, "Functionality of " - "lseek() on %s successful", TEMP_FILE); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and write some - * data into it. - * Get the size of the file using fstat(). - */ -void -setup() -{ - struct stat stat_buf; /* struct buffer for stat(2) */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Get the data to be written to temporary file */ - strcpy(write_buf1, "abcdefg"); - strcpy(write_buf2, "ijk"); - - /* Creat/open a temporary file for writing under above directory */ - if ((fildes = open(TEMP_FILE, O_WRONLY | O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_WRONLY|O_CREAT, %#o) Failed, errno=%d :%s", - TEMP_FILE, FILE_MODE, errno, strerror(errno)); - } - - /* Write data into temporary file */ - if(write(fildes, write_buf1, strlen(write_buf1)) != - (int)strlen(write_buf1)) { - tst_brkm(TBROK, cleanup, "write(2) on %s Failed, errno=%d : %s", - TEMP_FILE, errno, strerror(errno)); - } - - /* Get the size of the temporary file after writing data */ - if (fstat(fildes, &stat_buf) < 0) { - tst_brkm(TBROK, cleanup, "fstat() on %s Failed, errno=%d : %s", - TEMP_FILE, errno, strerror(errno)); - } - - file_size = stat_buf.st_size; -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Close the temporary file created */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, NULL, "close(%s) Failed, errno=%d : %s:", - TEMP_FILE, errno, strerror(errno)); - } - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/lseek08.c b/winsup/testsuite/winsup.api/ltp/lseek08.c deleted file mode 100644 index 32fdcc0e4..000000000 --- a/winsup/testsuite/winsup.api/ltp/lseek08.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: lseek03 - * - * Test Description: - * Verify that, lseek() call succeeds to set the file pointer position - * to the end of the file when 'whence' value set to SEEK_END and any - * attempts to read from that position should fail. - * - * Expected Result: - * lseek() should return the offset which is set to the file size measured - * in bytes. read() attempt should fail with -1 return value. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * lseek03 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMP_FILE "tmp_file" -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH - -const char *TCID="lseek03"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -int fildes; /* file handle for temp file */ -ssize_t file_size; /* size of the temporary file */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - char read_buf[1]; /* data read from temp. file */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Invoke lseek(2) to move the read/write file - * pointer/handle to the END of the file. - */ - TEST(lseek(fildes, 0, SEEK_END)); - - /* check return code of lseek(2) */ - if (TEST_RETURN == (off_t)-1) { - tst_resm(TFAIL, "lseek on (%s) Failed, errno=%d : %s", - TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Check if the return value from lseek(2) - * is equal to the file_size. - */ - if (TEST_RETURN != file_size) { - tst_resm(TFAIL, "lseek() returned incorrect " - "value %d, expected %d", - TEST_RETURN, file_size); - continue; - } - /* - * The return value is okay, now attempt to read data - * from the file. This should fail as the file pointer - * should be pointing to END OF FILE. - */ - read_buf[0] = '\0'; - if (read(fildes, &read_buf, sizeof(read_buf)) > 0) { - tst_resm(TFAIL, "read() successful on %s", - TEMP_FILE); - } else { - tst_resm(TPASS, "Functionality of lseek() on " - "%s successful", TEMP_FILE); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /* NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and write some - * data into it. - * Get the size of the file using fstat(). - */ -void -setup() -{ - struct stat stat_buf; /* struct. buffer for stat(2) */ - char write_buf[BUFSIZ]; /* buffer to hold data */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Get the data to be written to temporary file */ - strcpy(write_buf, "abcdefg\n"); - - /* Creat/open a temporary file under above directory */ - if ((fildes = open(TEMP_FILE, O_RDWR | O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s", - TEMP_FILE, FILE_MODE, errno, strerror(errno)); - } - - /* Write data into temporary file */ - if(write(fildes, write_buf, strlen(write_buf)) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TEMP_FILE, errno, strerror(errno)); - } - - /* Get the size of the file using fstat */ - if (fstat(fildes, &stat_buf) < 0) { - tst_brkm(TBROK, cleanup, - "fstat(2) on %s Failed, errno=%d : %s", - TEMP_FILE, errno, strerror(errno)); - } - - file_size = stat_buf.st_size; -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Close the temporary file created */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, NULL, - "close(%s) Failed, errno=%d : %s:", - TEMP_FILE, errno, strerror(errno)); - } - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/lseek09.c b/winsup/testsuite/winsup.api/ltp/lseek09.c deleted file mode 100644 index 36688c656..000000000 --- a/winsup/testsuite/winsup.api/ltp/lseek09.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: lseek04 - * - * Test Description: - * Verify that, lseek() call succeeds to set the file pointer position - * to the current specified location, when 'whence' value is set to - * SEEK_CUR and the data read from the specified location should match - * the expected data. - * - * Expected Result: - * lseek() should return the specified offset from the beginning of the file - * measured in bytes. The data read from this location should match the - * expected data. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * lseek04 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMP_FILE "tmp_file" -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH - -const 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 fildes; /* file handle for temp file */ -size_t file_size; /* total size of file after data write */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - char read_buf[BUFSIZ]; /* data read from temp. file */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Invoke lseek(2) to set the file - * pointer/handle from the current location - * of the file descriptor + specified offset. - */ - TEST(lseek(fildes, 1, SEEK_CUR)); - - /* check return code of lseek(2) */ - if (TEST_RETURN == (off_t)-1) { - tst_resm(TFAIL, "lseek on (%s) Failed, errno=%d : %s", - TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Check if the return value from lseek(2) is equal - * to the 3 positions from the beginning of the file. - * ie, 2 positions from lseek() in the setup + - * 1 position from above above. - */ - if (TEST_RETURN != 3) { - tst_resm(TFAIL, "lseek() returned incorrect " - "value %d, expected 4", TEST_RETURN); - continue; - } - /* - * Read the data byte from this location. - */ - read_buf[0] = '\0'; - if (read(fildes, &read_buf, (file_size - 3)) < 0) { - tst_brkm(TFAIL, cleanup, - "read() failed on %s, error=%d", - TEMP_FILE, errno); - } else { - /* - * Check if read data contains - * expected characters - * From pos 4 ---> 'defg'. - */ - if (memcmp(read_buf, "defg", 4)) { - tst_resm(TFAIL, "Incorrect data read " - "from file %s", TEMP_FILE); - } else { - tst_resm(TPASS, "Functionality of " - "lseek() on %s successful", - TEMP_FILE); - } - } - } else { - tst_resm(TPASS, "call succeeded"); - } - - /* reset file pointer in case we are looping */ - if (lseek(fildes, 2, SEEK_SET) == -1) { - tst_brkm(TBROK, cleanup, "lseek failed - could not " - "reset file pointer"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and write some - * data into it. - * Get the size of the file using fstat(). - */ -void -setup() -{ - struct stat stat_buf; /* buffer to hold stat info. */ - char write_buf[BUFSIZ]; /* buffer to hold data */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Get the data to be written to temporary file */ - strcpy(write_buf, "abcdefg"); - - /* Creat/open a temporary file under above directory */ - if ((fildes = open(TEMP_FILE, O_RDWR | O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s", - TEMP_FILE, FILE_MODE, errno, strerror(errno)); - } - - /* Write data into temporary file */ - if(write(fildes, write_buf, strlen(write_buf)) <= 0) { - tst_brkm(TBROK, cleanup, "write(2) on %s Failed, errno=%d : %s", - TEMP_FILE, errno, strerror(errno)); - } - - /* Get the temporary file information */ - if (fstat(fildes, &stat_buf) < 0) { - tst_brkm(TBROK, cleanup, "fstat(2) on %s Failed, errno=%d : %s", - TEMP_FILE, errno, strerror(errno)); - } - - file_size = stat_buf.st_size; - - /* - * Reset the file pointer position to the specified offset - * from the beginning of the file. - */ - if (lseek(fildes, 2, SEEK_SET) != 2) { - tst_brkm(TBROK, cleanup, - "lseek() fails to set file ptr. to specified offset"); - } -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Close the temporary file created */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, NULL, "close(%s) Failed, errno=%d : %s:", - TEMP_FILE, errno, strerror(errno)); - } - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/lseek10.c b/winsup/testsuite/winsup.api/ltp/lseek10.c deleted file mode 100644 index ab3cc6ba3..000000000 --- a/winsup/testsuite/winsup.api/ltp/lseek10.c +++ /dev/null @@ -1,344 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: lseek05 - * - * Test Description: - * Verify that, - * 1. lseek() returns -1 and sets errno to ESPIPE, if the file handle of - * the specified file is associated with a pipe, socket, or FIFO. - * 2. lseek() returns -1 and sets errno to EINVAL, if the 'Whence' argument - * is not a proper value. - * 3. lseek() returns -1 and sets errno to EBADF, if the file handle of - * the specified file is not valid. - * - * Expected Result: - * lseek() should fail with return value -1 and set expected errno. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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) - * if errno set == expected errno - * Issue sys call fails with expected return value and errno. - * Otherwise, - * Issue sys call fails with unexpected errno. - * Otherwise, - * Issue sys call returns unexpected value. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory(s)/file(s) created. - * - * Usage: - * lseek05 [-c n] [-e] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMP_FILE1 "tmp_file1" -#define TEMP_FILE2 "tmp_file2" -#define TEMP_FILE3 "tmp_file3" -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define PIPE_MODE S_IFIFO | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define SEEK_TOP 10 - -const char *TCID="lseek05"; /* 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[]={ESPIPE, EINVAL, EBADF, 0}; - -int no_setup(); -int setup1(); /* setup function to test lseek() for ESPIPE */ -int setup2(); /* setup function to test lseek() for EINVAL */ -int setup3(); /* setup function to test lseek() for EBADF */ - -int fd1; /* file handle for testfile1 */ -int fd2; /* file handle for testfile2 */ -int fd3; /* file handle for testfile3 */ - -struct test_case_t { /* test case struct. to hold ref. test cond's*/ - int fd; - int Whence; - const char *desc; - int exp_errno; - int (*setupfunc)(); -} Test_cases[] = { - { 1, SEEK_SET, "'fd' associated with a pipe/fifo", ESPIPE, setup1 }, - { 2, SEEK_TOP, "'whence' argument is not valid", EINVAL, setup2 }, - { 3, SEEK_SET, "'fd' is not an open file descriptor", EBADF, setup3 }, - { 0, 0, NULL, 0, no_setup } -}; - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - int fildes; /* file handle for testfile */ - int whence; /* position of file handle in the file */ - const char *test_desc; /* test specific error message */ - int ind; /* counter to test different test conditions */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (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 -i 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++) { - fildes = Test_cases[ind].fd; - test_desc = Test_cases[ind].desc; - whence = Test_cases[ind].Whence; - - /* Assign the 'fd' values appropriatly */ - if (fildes == 1) { - fildes = fd1; - } else if (fildes == 2) { - fildes = fd2; - } else { - fildes = fd3; - } - /* - * Invoke lseek(2) to test different test conditions. - * Verify that it fails with -1 return value and - * sets appropriate errno. - */ - TEST(lseek(fildes, 0, whence)); - - /* check return code of lseek(2) */ - if (TEST_RETURN != (off_t)-1) { - tst_resm(TFAIL, "lseek() returned %d, expected " - "-1, errno:%d", TEST_RETURN, - Test_cases[ind].exp_errno); - continue; - } - TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO == Test_cases[ind].exp_errno) { - tst_resm(TPASS, "lseek() fails, %s, errno:%d", - test_desc, TEST_ERRNO); - } else { - tst_resm(TFAIL, "lseek() fails, %s, errno:%d, " - "expected errno:%d", test_desc, - TEST_ERRNO, Test_cases[ind].exp_errno); - } - } - } - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Invoke individual test setup functions according to the order - * set in test struct. definition. - */ -void -setup() -{ - int ind; /* counter for test setup function */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* call individual setup functions */ - for (ind = 0; Test_cases[ind].desc != NULL; ind++) { - Test_cases[ind].setupfunc(); - } -} - -/* - * no_setup() - This is a dummy function which simply returns 0. - */ -int -no_setup() -{ - return 0; -} - -/* - * setup1() - setup function for a test condition for which lseek(2) - * returns -1 and sets errno to ESPIPE. - * Creat a named pipe/fifo using mknod() and open it for - * reading/writing. - * This function returns 0 on success. - */ -int -setup1() -{ - /* Creat a named pipe/fifo using mknod() */ - if (mknod(TEMP_FILE1, PIPE_MODE, 0) < 0) { - tst_brkm(TBROK, cleanup, - "mknod(%s, %#o, 0) Failed, errno=%d :%s", - TEMP_FILE1, FILE_MODE, errno, strerror(errno)); - } - - /* Open the named pipe/fifo for reading/writing */ - if ((fd1 = open(TEMP_FILE1, O_RDWR)) < 0) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR) Failed, errno=%d, :%s", - TEMP_FILE1, errno, strerror(errno)); - } - - return 0; -} - -/* - * setup2() - setup function for a test condition for which lseek(2) - * returns -1 and sets errno to EINVAL. - * Creat a temporary file for reading/writing and write some data - * into it. - * This function returns 0 on success. - */ -int -setup2() -{ - char write_buff[BUFSIZ]; /* buffer to hold data */ - - /* Get the data to be written to temporary file */ - strcpy(write_buff, "abcdefg"); - - /* Creat/open a temporary file under above directory */ - if ((fd2 = open(TEMP_FILE2, O_RDWR | O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s", - TEMP_FILE2, FILE_MODE, errno, strerror(errno)); - } - - /* Write data into temporary file */ - if(write(fd2, write_buff, sizeof(write_buff)) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TEMP_FILE2, errno, strerror(errno)); - } - - return 0; -} - -/* - * setup3() - setup function for a test condition for which lseek(2) - * returns -1 and sets errno to EBADF. - * Creat a temporary file for reading/writing and close it. - * This function returns 0 on success. - */ -int -setup3() -{ - /* Creat/open a temporary file under above directory */ - if ((fd3 = open(TEMP_FILE3, O_RDWR | O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d :%s", - TEMP_FILE3, FILE_MODE, errno, strerror(errno)); - } - - /* Close the temporary file created above */ - if (close(fd3) < 0) { - tst_brkm(TBROK, cleanup, - "close(%s) Failed, errno=%d : %s:", - TEMP_FILE3, errno, strerror(errno)); - } - - return 0; -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test directory and testfile(s) created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Close the temporary file(s) created in setup1/setup2*/ - if (close(fd1) < 0) { - tst_brkm(TFAIL, NULL, - "close(%s) Failed, errno=%d : %s:", - TEMP_FILE1, errno, strerror(errno)); - } - if (close(fd2) < 0) { - tst_brkm(TFAIL, NULL, - "close(%s) Failed, errno=%d : %s:", - TEMP_FILE2, errno, strerror(errno)); - } - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/lstat02.c b/winsup/testsuite/winsup.api/ltp/lstat02.c deleted file mode 100644 index eed8f78c7..000000000 --- a/winsup/testsuite/winsup.api/ltp/lstat02.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 5772f0683..000000000 --- a/winsup/testsuite/winsup.api/ltp/mkdir01.c +++ /dev/null @@ -1,270 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - -char *get_high_address(); - -const 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 */ - const 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 deleted file mode 100644 index d1cc19344..000000000 --- a/winsup/testsuite/winsup.api/ltp/mkdir08.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 6cfe4885a..000000000 --- a/winsup/testsuite/winsup.api/ltp/mknod01.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - * 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 -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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 - * Aaron Laffin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -const char *TCID="mmap001"; -int TST_TOTAL=5; -extern int Tst_count; -static char *filename=NULL; -static int m_opt = 0; -static char *m_copt; - -void cleanup() -{ - /* - * remove the tmp directory and exit - */ - - if ( filename ) - free(filename); - - TEST_CLEANUP; - - tst_rmdir(); - - tst_exit(); -} - -void setup() -{ - char buf[1024]; - /* - * setup a default signal hander and a - * temporary working directory. - */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - tst_tmpdir(); - - TEST_PAUSE; - - snprintf(buf,1024,"testfile.%d",getpid()); - - filename = strdup(buf); -} - -void help() -{ - printf(" -m x size of mmap in pages (default 1000)\n"); -} - -/* - * add the -m option whose parameter is the - * pages that should be mapped. - */ -option_t options[] = -{ - { "m:", &m_opt, &m_copt }, - { NULL, NULL, NULL } -}; - -int main(int argc, char * argv[]) -{ - char *array; - const char *msg; - int i,lc; - int fd; - int pages,memsize; - - if ( (msg=parse_opts(argc, argv, options, help)) != (char *) NULL ) - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - - if ( m_opt ) - { - memsize = pages = atoi( m_copt ); - - if (memsize < 1) - { - tst_brkm(TBROK, cleanup, "Invalid arg for -m: %s",m_copt); - } - - memsize *= getpagesize(); /* N PAGES */ - - } - else - { - /* - * default size 1000 pages; - */ - memsize = pages = 1000; - memsize *= getpagesize(); - } - - tst_resm(TINFO,"mmap()ing file of %u pages or %u bytes", pages,memsize); - - setup(); - - for (lc=0; TEST_LOOPING(lc); lc++) - { - Tst_count=0; - - fd = open(filename, O_RDWR | O_CREAT, 0666); - if ((fd == -1)) - tst_brkm(TBROK, cleanup, "Problems opening files"); - - if (lseek(fd, memsize, SEEK_SET) != memsize) - { - close(fd); - tst_brkm(TBROK, cleanup, "Problems doing the lseek: %d: %s", - errno,strerror(errno)); - } - - if (write(fd,"\0",1) !=1) - { - close(fd); - tst_brkm(TBROK, cleanup, "Problems writing: %d: %s", - errno,strerror(errno)); - } - - array = mmap(0, memsize, PROT_WRITE, MAP_SHARED,fd,0); - if (array == (char *)MAP_FAILED) - { - tst_resm(TFAIL, "mmap() failed: %d: %s", - errno,strerror(errno)); - tst_exit(); - } - else - { - tst_resm(TPASS, "mmap() completed successfully."); - } - - if ( STD_FUNCTIONAL_TEST ) - { - tst_resm(TINFO,"touching mmaped memory"); - - for(i = 0; i < memsize; i++) - { - array[i] = (char) i; - } - - /* - * seems that if the map area was bad, we'd get SEGV, hence we can - * indicate a PASS. - */ - tst_resm(TPASS, "we're still here, mmaped area must be good"); - - TEST( msync(array, memsize, MS_SYNC) ); - - if ( TEST_RETURN == -1 ) - { - tst_resm(TFAIL, "msync() failed: errno: %d: %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - } - else - { - tst_resm(TPASS, "msync() was successful"); - } - - } /* STD_FUNCTIONAL_TEST */ - - TEST( munmap(array, memsize) ); - - if ( TEST_RETURN == -1 ) - { - tst_resm(TFAIL, "munmap() failed: errno: %d: %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - } - else - { - tst_resm(TPASS, "munmap() was successful"); - } - - close(fd); - unlink(filename); - } - cleanup(); - return 0; -} diff --git a/winsup/testsuite/winsup.api/ltp/mmap02.c b/winsup/testsuite/winsup.api/ltp/mmap02.c deleted file mode 100644 index 33a12738c..000000000 --- a/winsup/testsuite/winsup.api/ltp/mmap02.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: mmap02 - * - * Test Description: - * Call mmap() with prot parameter set to PROT_READ and with the file - * descriptor being open for read, to map a file creating mapped memory - * with read access. The minimum file permissions should be 0444. - * - * The call should succeed to create the mapped region with required - * attributes. - * - * Expected Result: - * mmap() should succeed returning the address of the mapped region, - * the mapped region should contain the contents of the mapped file. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * Create temporary directory. - * - * 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, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * mmap02 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMPFILE "mmapfile" - -const char *TCID="mmap02"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -char *addr; /* addr of memory mapped region */ -char *dummy; /* dummy string */ -size_t page_sz; /* system page size */ -int fildes = -1; /* file descriptor for temporary file */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call mmap to map the temporary file 'TEMPFILE' - * with read access. - */ - TEST(mmap(0, page_sz, PROT_READ, - MAP_FILE|MAP_SHARED, fildes, 0)); - - /* Check for the return value of mmap() */ - if (TEST_RETURN == (int)MAP_FAILED) { - tst_resm(TFAIL, "mmap() Failed on %s, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* Get the mmap return value */ - addr = (char *)TEST_RETURN; - - /* - * Read the file contents into the dummy - * string. - */ - if (read(fildes, dummy, page_sz) < 0) { - tst_brkm(TFAIL, cleanup, "read() on %s Failed, " - "error:%d", TEMPFILE, errno); - } - - /* - * Check whether mapped memory region has - * the file contents. - */ - if (memcmp(dummy, addr, page_sz)) { - tst_resm(TFAIL, "mapped memory area contains " - "invalid data"); - } else { - tst_resm(TPASS, - "Functionality of mmap() successful"); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - - /* Clean up things in case we are looping */ - /* Unmap the mapped memory */ - if (munmap(addr, page_sz) != 0) { - tst_brkm(TFAIL, NULL, "munmap() fails to unmap the " - "memory, errno=%d", errno); - } - - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * - * Get system page size, allocate and initialize the string dummy. - * Initialize addr such that it is more than one page below the break - * address of the process, and initialize one page region from addr - * with char 'A'. - * Create a temporary directory a file under it. - * Write some known data into file and close it. - * Change mode permissions on file to 0444. - */ -void -setup() -{ - char *tst_buff; /* test buffer to hold known data */ - - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Get the system page size */ - if ((page_sz = getpagesize()) < 0) { - tst_brkm(TFAIL, NULL, - "getpagesize() fails to get system page size"); - tst_exit(); - } - - /* Allocate space for the test buffer */ - if ((tst_buff = (char *)calloc(page_sz, sizeof(char))) == NULL) { - tst_brkm(TFAIL, NULL, - "calloc() failed to allocate space for tst_buff"); - tst_exit(); - } - - /* Fill the test buffer with the known data */ - memset(tst_buff, 'A', page_sz); - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666)) < 0) { - tst_brkm(TFAIL, NULL, "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Write test buffer contents into temporary file */ - if (write(fildes, tst_buff, sizeof(tst_buff)) < (int)sizeof(tst_buff)) { - tst_brkm(TFAIL, NULL, "write() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Free the memory allocated for test buffer */ - free(tst_buff); - - /* Close the temporary file */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, cleanup, "close() Failed on %s, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } - - /* Change Mode permissions on Temporary file */ - if (chmod(TEMPFILE, 0444) < 0) { - tst_brkm(TFAIL, cleanup, "chmod(%s, 0444) Failed, errno=%d : " - "%s", TEMPFILE, errno, strerror(errno)); - } - - /* Open the temporary file again, - Readonly mode */ - if ((fildes = open(TEMPFILE, O_RDONLY)) < 0) { - tst_brkm(TFAIL, cleanup, "open(%s, O_RDONLY) Failed, errno=%d " - ": %s", TEMPFILE, errno, strerror(errno)); - } - - - /* Allocate and initialize dummy string of system page size bytes */ - if ((dummy = (char *)calloc(page_sz, sizeof(char))) == NULL) { - tst_brkm(TFAIL, NULL, "calloc() failed to allocate space"); - tst_exit(); - } - -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Free the memory allocated to dummy variable. - * Remove the temporary directory created. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - */ - TEST_CLEANUP; - - /* Free the memory allocated for dummy string */ - if (dummy) { - free(dummy); - } - - if (fildes >= 0) - close (fildes); - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/mmap03.c b/winsup/testsuite/winsup.api/ltp/mmap03.c deleted file mode 100644 index 9302d335d..000000000 --- a/winsup/testsuite/winsup.api/ltp/mmap03.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: mmap03 - * - * Test Description: - * Call mmap() to map a file creating a mapped region with execute access - * under the following conditions - - * - The prot parameter is set to PROT_EXE - * - The file descriptor is open for read - * - The file being mapped has execute permission bit set. - * - The minimum file permissions should be 0555. - * - * The call should succeed to map the file creating mapped memory with the - * required attributes. - * - * Expected Result: - * mmap() should succeed returning the address of the mapped region, - * and the mapped region should contain the contents of the mapped file. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * Create temporary directory. - * - * 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, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * mmap03 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMPFILE "mmapfile" - -const char *TCID="mmap03"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -size_t page_sz; /* system page size */ -char *addr; /* addr of memory mapped region */ -char *dummy; /* dummy variable to hold temp file contents */ -int fildes = -1; /* file descriptor for temporary file */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call mmap to map the temporary file 'TEMPFILE' - * with execute access. - */ - TEST(mmap(0, page_sz, PROT_EXEC, - MAP_FILE|MAP_SHARED, fildes, 0)); - - /* Check for the return value of mmap() */ - if (TEST_RETURN == (int)MAP_FAILED) { - tst_resm(TFAIL, "mmap() Failed on %s, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* Get the mmap return value */ - addr = (char *)TEST_RETURN; - - /* - * Read the file contents into the dummy - * variable. - */ - if (read(fildes, dummy, page_sz) < 0) { - tst_brkm(TFAIL, cleanup, "read() on %s Failed, " - "error:%d", TEMPFILE, errno); - } - - /* - * Check whether the mapped memory region - * has the file contents. - */ - if (memcmp(dummy, addr, page_sz)) { - tst_resm(TFAIL, "mapped memory region contains " - "invalid data"); - } else { - tst_resm(TPASS, - "Functionality of mmap() successful"); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - - /* Clean up things in case we are looping */ - /* Unmap the mapped memory */ - if (munmap(addr, page_sz) != 0) { - tst_brkm(TFAIL, NULL, "munmap() fails to unmap the " - "memory, errno=%d", errno); - } - - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Get the system page size. - * Create a temporary directory and a file under it. - * Write some known data into file and close it. - * Change the mode permissions on file to 0555. - * Re-open the file for reading. - */ -void -setup() -{ - char *tst_buff; /* test buffer to hold known data */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Get the system page size */ - if ((page_sz = getpagesize()) < 0) { - tst_brkm(TFAIL, NULL, - "getpagesize() fails to get system page size"); - tst_exit(); - } - - /* Allocate space for the test buffer */ - if ((tst_buff = (char *)calloc(page_sz, sizeof(char))) == NULL) { - tst_brkm(TFAIL, NULL, - "calloc() failed to allocate space for tst_buff"); - tst_exit(); - } - - /* Fill the test buffer with the known data */ - memset(tst_buff, 'A', page_sz); - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_WRONLY | O_CREAT, 0666)) < 0) { - tst_brkm(TFAIL, NULL, "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Write test buffer contents into temporary file */ - if (write(fildes, tst_buff, strlen(tst_buff)) < (int)strlen(tst_buff)) { - tst_brkm(TFAIL, NULL, "write() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Free the memory allocated for test buffer */ - free(tst_buff); - - /* Make sure proper permissions set on file */ - if (chmod(TEMPFILE, 0555) < 0) { - tst_brkm(TFAIL, cleanup, "chmod() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } - - /* Close the temporary file opened for write */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, cleanup, "close() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } - - /* Allocate and initialize dummy string of system page size bytes */ - if ((dummy = (char *)calloc(page_sz, sizeof(char))) == NULL) { - tst_brkm(TFAIL, cleanup, - "calloc() failed to allocate memory for dummy"); - } - - /* Open the temporary file again for reading */ - if ((fildes = open(TEMPFILE, O_RDONLY)) < 0) { - tst_brkm(TFAIL, cleanup, "open(%s) with read-only Failed, " - "errno:%d", TEMPFILE, errno); - } -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - Free the memory allocated to dummy variable. - * Remove the temporary directory created. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - */ - TEST_CLEANUP; - - /* Free the memory space allocated for dummy variable */ - if (dummy) { - free(dummy); - } - - if (fildes >= 0) - close (fildes); - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/mmap04.c b/winsup/testsuite/winsup.api/ltp/mmap04.c deleted file mode 100644 index 64d3a8ebe..000000000 --- a/winsup/testsuite/winsup.api/ltp/mmap04.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: mmap04 - * - * Test Description: - * Call mmap() to map a file creating a mapped region with read/exec access - * under the following conditions - - * - The prot parameter is set to PROT_READ|PROT_EXEC - * - The file descriptor is open for read - * - The file being mapped has read and execute permission bit set. - * - The minimum file permissions should be 0555. - * - * The call should succeed to map the file creating mapped memory with the - * required attributes. - * - * Expected Result: - * mmap() should succeed returning the address of the mapped region, - * and the mapped region should contain the contents of the mapped file. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * Create temporary directory. - * - * 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, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * mmap04 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMPFILE "mmapfile" - -const char *TCID="mmap04"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -size_t page_sz; /* system page size */ -char *addr; /* addr of memory mapped region */ -char *dummy; /* dummy variable to hold temp file contents */ -int fildes = -1; /* file descriptor for temporary file */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call mmap to map the temporary file 'TEMPFILE' - * with read and execute access. - */ - TEST(mmap(0, page_sz, PROT_READ|PROT_EXEC, - MAP_FILE|MAP_SHARED, fildes, 0)); - - /* Check for the return value of mmap() */ - if (TEST_RETURN == (int)MAP_FAILED) { - tst_resm(TFAIL, "mmap() Failed on %s, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - continue; - } - - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* Get the mmap return value */ - addr = (char *)TEST_RETURN; - - /* - * Read the file contents into the dummy - * variable. - */ - if (read(fildes, dummy, page_sz) < 0) { - tst_brkm(TFAIL, cleanup, "read() on %s Failed, " - "error:%d", TEMPFILE, errno); - } - - /* - * Check whether the mapped memory region - * has the file contents. - */ - if (memcmp(dummy, addr, page_sz)) { - tst_resm(TFAIL, "mapped memory region contains " - "invalid data"); - } else { - tst_resm(TPASS, - "Functionality of mmap() successful"); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - /* Clean up things in case we are looping. */ - /* Unmap the mapped memory */ - if (munmap(addr, page_sz) != 0) { - tst_brkm(TFAIL, NULL, "munmap() fails to unmap the " - "memory, errno=%d", errno); - } - - - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Get the system page size. - * Create a temporary directory and a file under it. - * Write some known data into file and close it. - * Change the mode permissions on file to 0555. - * Re-open the file for reading. - */ -void -setup() -{ - char *tst_buff; /* test buffer to hold known data */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Get the system page size */ - if ((page_sz = getpagesize()) < 0) { - tst_brkm(TFAIL, NULL, - "getpagesize() fails to get system page size"); - tst_exit(); - } - - if ((tst_buff = (char *)calloc(page_sz, sizeof(char))) == NULL) { - tst_brkm(TFAIL, NULL, - "calloc() failed to allocate space for tst_buff"); - tst_exit(); - } - - /* Fill the test buffer with the known data */ - memset(tst_buff, 'A', page_sz); - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_WRONLY | O_CREAT, 0666)) < 0) { - tst_brkm(TFAIL, NULL, "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Write test buffer contents into temporary file */ - if (write(fildes, tst_buff, strlen(tst_buff)) < (int)strlen(tst_buff)) { - tst_brkm(TFAIL, NULL, "write() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Free the memory allocated for test buffer */ - free(tst_buff); - - /* Make sure proper permissions set on file */ - if (chmod(TEMPFILE, 0555) < 0) { - tst_brkm(TFAIL, cleanup, "chmod() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } - - /* Close the temporary file opened for write */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, cleanup, "close() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } - - /* Allocate and initialize dummy string of system page size bytes */ - if ((dummy = (char *)calloc(page_sz, sizeof(char))) == NULL) { - tst_brkm(TFAIL, cleanup, - "calloc() failed to allocate memory for dummy"); - } - - /* Open the temporary file again for reading */ - if ((fildes = open(TEMPFILE, O_RDONLY)) < 0) { - tst_brkm(TFAIL, cleanup, "open(%s) with read-only Failed, " - "errno:%d", TEMPFILE, errno); - } -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Free the memeory allocated to dummy variable. - * Remove the temporary directory created. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Free the memory space allocated for dummy variable */ - if (dummy) { - free(dummy); - } - - if (fildes >= 0) - close (fildes); - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/mmap05.c b/winsup/testsuite/winsup.api/ltp/mmap05.c deleted file mode 100644 index bcdfd0cd8..000000000 --- a/winsup/testsuite/winsup.api/ltp/mmap05.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: mmap05 - * - * Test Description: - * Call mmap() to map a file creating mapped memory with no access under - * the following conditions - - * - The prot parameter is set to PROT_NONE - * - The file descriptor is open for read(any mode other than write) - * - The minimum file permissions should be 0444. - * - * The call should succeed to map the file creating mapped memory with the - * required attributes. - * - * Expected Result: - * mmap() should succeed returning the address of the mapped region, - * and an attempt to access the contents of the mapped region should give - * rise to the signal SIGSEGV. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * Create temporary directory. - * - * 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, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * mmap05 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMPFILE "mmapfile" - -const char *TCID="mmap05"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -size_t page_sz; /* system page size */ -char *addr; /* addr of memory mapped region */ -int fildes = -1; /* file descriptor for temporary file */ -int pass=0; /* pass flag perhaps set to 1 in sig_handler */ -sigjmp_buf env; /* environment for sigsetjmp/siglongjmp */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ -void sig_handler(); /* signal handler to catch SIGSEGV */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - volatile char file_content; /* tempfile content */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call mmap to map the temporary file 'TEMPFILE' - * with no access. - */ - - TEST(mmap(0, page_sz, PROT_NONE, - MAP_FILE|MAP_SHARED, fildes, 0)); - - /* Check for the return value of mmap() */ - if (TEST_RETURN == (int)MAP_FAILED) { - tst_resm(TFAIL, "mmap() Failed on %s, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - continue; - } - - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - - /* - * Try to access the mapped region. This should - * generate a SIGSEGV which will be caught below. - * - * This is wrapped by the sigsetjmp() call that will - * take care of restoring the program's context in an - * elegant way in conjunction with the call to - * siglongjmp() in the signal handler. - */ - if (sigsetjmp(env, 1) == 0) { - file_content = addr[0]; - } - - if (pass) { - tst_resm(TPASS, "Got SIGSEGV as expected"); - } else { - tst_resm(TFAIL, "Mapped memory region with NO " - "access is accessible"); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - - /* Unmap mapped memory and reset pass in case we are looping */ - if (munmap(addr, page_sz) != 0) { - tst_brkm(TFAIL, cleanup, "munmap() fails to unmap the " - "memory, errno=%d", errno); - } - pass = 0; - - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Get the system page size. - * Create a temporary directory and a file under it. - * Write some known data into file and close it. - * Change the mode permissions on file to 0444 - * Re-open the file for reading. - */ -void -setup() -{ - char *tst_buff; /* test buffer to hold known data */ - - /* capture signals */ - tst_sig(NOFORK, sig_handler, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Get the system page size */ - if ((page_sz = getpagesize()) < 0) { - tst_brkm(TFAIL, NULL, - "getpagesize() fails to get system page size"); - tst_exit(); - } - - /* Allocate space for the test buffer */ - if ((tst_buff = (char *)calloc(page_sz, sizeof(char))) == NULL) { - tst_brkm(TFAIL, NULL, - "calloc() failed to allocate space for tst_buff"); - tst_exit(); - } - - /* Fill the test buffer with the known data */ - memset(tst_buff, 'A', page_sz); - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_WRONLY | O_CREAT, 0666)) < 0) { - tst_brkm(TFAIL, NULL, "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Write test buffer contents into temporary file */ - if (write(fildes, tst_buff, strlen(tst_buff)) - != (int)strlen(tst_buff)) { - tst_brkm(TFAIL, NULL, "write() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Free the memory allocated for test buffer */ - free(tst_buff); - - /* Close the temporary file opened for write */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, cleanup, "close() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } - - /* Make sure proper permissions set on file */ - if (chmod(TEMPFILE, 0444) < 0) { - tst_brkm(TFAIL, cleanup, "chmod() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } - - /* Open the temporary file again for reading */ - if ((fildes = open(TEMPFILE, O_RDONLY)) < 0) { - tst_brkm(TFAIL, cleanup, "open(%s) with read-only Failed, " - "errno:%d", TEMPFILE, errno); - } -} - -/* - * sig_handler() - Signal Cathing function. - * This function gets executed when the test process receives - * the signal SIGSEGV while trying to access the contents of memory which - * is not accessible. - */ -void -sig_handler(sig) -{ - if (sig == SIGSEGV) { - /* set the global variable and jump back */ - pass = 1; - siglongjmp(env, 1); - } else { - tst_brkm(TBROK, cleanup, "received an unexpected signal"); - } -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory created. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - if (fildes >= 0) - close (fildes); - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/mmap06.c b/winsup/testsuite/winsup.api/ltp/mmap06.c deleted file mode 100644 index ec113c077..000000000 --- a/winsup/testsuite/winsup.api/ltp/mmap06.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: mmap06 - * - * Test Description: - * Call mmap() to map a file creating a mapped region with read access - * under the following conditions - - * - The prot parameter is set to PROT_READ - * - The file descriptor is open for writing. - * - * The call should fail to map the file. - * - * Expected Result: - * mmap() should fail returning -1 and errno should get set to EACCES. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * Create temporary directory. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * if errno set == expected errno - * Issue sys call fails with expected return value and errno. - * Otherwise, - * Issue sys call fails with unexpected errno. - * Otherwise, - * Issue sys call returns unexpected value. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory(s)/file(s) created. - * - * Usage: - * mmap06 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMPFILE "mmapfile" - -const char *TCID="mmap06"; /* 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[]={EACCES, 0}; - -size_t page_sz; /* system page size */ -char *addr; /* addr of memory mapped region */ -int fildes = -1; /* file descriptor for temporary file */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (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 -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call mmap to map the temporary file 'TEMPFILE' - * with read access. - */ - TEST(mmap(0, page_sz, PROT_READ, - MAP_FILE|MAP_SHARED, fildes, 0)); - - /* Check for the return value of mmap() */ - if (TEST_RETURN != (int)MAP_FAILED) { - tst_resm(TFAIL, "mmap() returned invalid value, " - "expected: -1"); - /* Unmap the mapped memory */ - if (munmap(addr, page_sz) != 0) { - tst_brkm(TBROK, cleanup, "munmap() failed"); - } - continue; - } - TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO == EACCES) { - tst_resm(TPASS, "mmap() fails, 'fd' doesn't allow " - "desired access, errno:%d", errno); - } else { - tst_resm(TFAIL, "mmap() fails, 'fd' doesn't allow " - "desired access, invalid errno:%d", errno); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Get the system page size. - * Create a temporary directory and a file under it. - * Write some known data into file. - */ -void -setup() -{ - char *tst_buff; /* test buffer to hold known data */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Get the system page size */ - if ((page_sz = getpagesize()) < 0) { - tst_brkm(TFAIL, NULL, - "getpagesize() fails to get system page size"); - tst_exit(); - } - - /* Allocate space for the test buffer */ - if ((tst_buff = (char *)calloc(page_sz, sizeof(char))) == NULL) { - tst_brkm(TFAIL, NULL, - "calloc() failed to allocate space for tst_buff"); - tst_exit(); - } - - /* Fill the test buffer with the known data */ - memset(tst_buff, 'A', page_sz); - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_WRONLY | O_CREAT, 0666)) < 0) { - tst_brkm(TFAIL, NULL, - "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Write test buffer contents into temporary file */ - if (write(fildes, tst_buff, strlen(tst_buff)) < (int)strlen(tst_buff)) { - tst_brkm(TFAIL, NULL, - "write() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Free the memory allocated for test buffer */ - free(tst_buff); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory created. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - if (fildes >= 0) - close (fildes); - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/mmap07.c b/winsup/testsuite/winsup.api/ltp/mmap07.c deleted file mode 100644 index ab989f443..000000000 --- a/winsup/testsuite/winsup.api/ltp/mmap07.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: mmap07 - * - * Test Description: - * Call mmap() to map a file creating a mapped region with read access - * under the following conditions - - * - The prot parameter is set to PROT_WRITE - * - The file descriptor is open for writing. - * - The flags parameter has MAP_PRIVATE set. - * - * The call should fail to map the file. - * - * Expected Result: - * mmap() should fail returning -1 and errno should get set to EACCES. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * Create temporary directory. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * if errno set == expected errno - * Issue sys call fails with expected return value and errno. - * Otherwise, - * Issue sys call fails with unexpected errno. - * Otherwise, - * Issue sys call returns unexpected value. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory(s)/file(s) created. - * - * Usage: - * mmap07 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMPFILE "mmapfile" - -const char *TCID="mmap07"; /* 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[]={EACCES, 0}; - -size_t page_sz; /* system page size */ -char *addr; /* addr of memory mapped region */ -int fildes = -1; /* file descriptor for temporary file */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (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 -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call mmap to map the temporary file 'TEMPFILE' - * with write access. - */ - TEST(mmap(0, page_sz, PROT_WRITE, - MAP_FILE|MAP_PRIVATE, fildes, 0)); - - /* Check for the return value of mmap() */ - if (TEST_RETURN != (int)MAP_FAILED) { - tst_resm(TFAIL, "mmap() returned invalid value, " - "expected: -1"); - /* Unmap the mapped memory */ - if (munmap(addr, page_sz) != 0) { - tst_brkm(TBROK, cleanup, "munmap() failed"); - } - continue; - } - TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO == EACCES) { - tst_resm(TPASS, "mmap() fails, 'fd' doesn't allow " - "desired access, errno:%d", errno); - } else { - tst_resm(TFAIL, "mmap() fails, 'fd' doesn't allow " - "desired access, invalid errno:%d", errno); - } - - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Get the system page size. - * Create a temporary directory and a file under it. - * Write some known data into file. - */ -void -setup() -{ - char *tst_buff; /* test buffer to hold known data */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Get the system page size */ - if ((page_sz = getpagesize()) < 0) { - tst_brkm(TFAIL, NULL, - "getpagesize() fails to get system page size"); - tst_exit(); - } - - /* Allocate space for the test buffer */ - if ((tst_buff = (char *)calloc(page_sz, sizeof(char))) == NULL) { - tst_brkm(TFAIL, NULL, - "calloc() failed to allocate space for tst_buff"); - tst_exit(); - } - - /* Fill the test buffer with the known data */ - memset(tst_buff, 'A', page_sz); - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_WRONLY | O_CREAT, 0666)) < 0) { - tst_brkm(TFAIL, NULL, "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Write test buffer contents into temporary file */ - if (write(fildes, tst_buff, strlen(tst_buff)) < (int)strlen(tst_buff)) { - tst_brkm(TFAIL, NULL, "write() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Free the memory allocated for test buffer */ - free(tst_buff); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory created. - */ -void -cleanup() -{ - /* - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - if (fildes >= 0) - close (fildes); - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/mmap08.c b/winsup/testsuite/winsup.api/ltp/mmap08.c deleted file mode 100644 index 543c5397b..000000000 --- a/winsup/testsuite/winsup.api/ltp/mmap08.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: mmap08 - * - * Test Description: - * Verify that mmap() fails to map a file creating a mapped region - * when the file specified by file descriptor is not valid. - * - * Expected Result: - * mmap() should fail returning -1 and errno should get set to EBADF. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * Create temporary directory. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * if errno set == expected errno - * Issue sys call fails with expected return value and errno. - * Otherwise, - * Issue sys call fails with unexpected errno. - * Otherwise, - * Issue sys call returns unexpected value. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory(s)/file(s) created. - * - * Usage: - * mmap08 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMPFILE "mmapfile" - -const char *TCID="mmap08"; /* 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[]={EBADF, 0}; - -size_t page_sz; /* system page size */ -char *addr; /* addr of memory mapped region */ -int fildes = -1; /* file descriptor for temporary file */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (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 -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call mmap to map the temporary file 'TEMPFILE' - * which is already closed. so, fildes is not valid. - */ - TEST(mmap(0, page_sz, PROT_WRITE, - MAP_FILE|MAP_SHARED, fildes, 0)); - - /* Check for the return value of mmap() */ - if (TEST_RETURN != (int)MAP_FAILED) { - tst_resm(TFAIL, "mmap() returned invalid value, " - "expected: -1"); - /* Unmap the mapped memory */ - if (munmap(addr, page_sz) != 0) { - tst_brkm(TBROK, cleanup, "munmap() failed"); - } - continue; - } - TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO == EBADF) { - tst_resm(TPASS, "mmap() fails, 'fd' is not valid, " - "errno:%d", errno); - } else { - tst_resm(TFAIL, "mmap() fails, 'fd' is not valid, " - "invalid errno:%d", errno); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Get the system page size. - * Create a temporary directory and a file under it. - * Write some known data into file and close it. - */ -void -setup() -{ - char *tst_buff; /* test buffer to hold known data */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Get the system page size */ - if ((page_sz = getpagesize()) < 0) { - tst_brkm(TFAIL, NULL, - "getpagesize() fails to get system page size"); - tst_exit(); - } - - if ((tst_buff = (char *)calloc(page_sz, sizeof(char))) == NULL) { - tst_brkm(TFAIL, NULL, - "calloc() failed to allocate space for tst_buff"); - tst_exit(); - } - - /* Fill the test buffer with the known data */ - memset(tst_buff, 'A', page_sz); - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_WRONLY | O_CREAT, 0666)) < 0) { - tst_brkm(TFAIL, NULL, "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Write test buffer contents into temporary file */ - if (write(fildes, tst_buff, strlen(tst_buff)) - != (int)strlen(tst_buff)) { - tst_brkm(TFAIL, NULL, "write() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - free(tst_buff); - cleanup(); - } - - /* Free the memory allocated for test buffer */ - free(tst_buff); - - /* Close the temporary file opened for writing */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, cleanup, "close() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory created. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - if (fildes >= 0) - close (fildes); - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/munmap01.c b/winsup/testsuite/winsup.api/ltp/munmap01.c deleted file mode 100644 index 0527201be..000000000 --- a/winsup/testsuite/winsup.api/ltp/munmap01.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: munmap01 - * - * Test Description: - * Verify that, munmap call will succeed to unmap a mapped file or - * anonymous shared memory region from the calling process's address space - * and after successful completion of munmap, the unmapped region is no - * longer accessible. - * - * Expected Result: - * munmap call should succeed to unmap a mapped file or anonymous shared - * memory region from the process's address space and it returns with a - * value 0, further reference to the unmapped region should result in a - * segmentation fault (SIGSEGV). - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * munmap01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMPFILE "mmapfile" - -const char *TCID="munmap01"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -char *addr; /* addr of memory mapped region */ -int fildes; /* file descriptor for tempfile */ -unsigned int map_len; /* length of the region to be mapped */ - -void setup(); /* Main setup function of test */ -void cleanup(void); /* cleanup function for the test */ -void sig_handler(); /* signal catching function */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *)NULL, NULL); - if (msg != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* Perform global setup for test */ - setup(); - - /* - * Call munmap to unmap the mapped region of the - * temporary file from the calling process's address space. - */ - TEST(munmap(addr, map_len)); - - /* Check for the return value of munmap() */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "munmap() fails, errno=%d : %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Check whether further reference is possible - * to the unmapped memory region by writing - * to the first byte of region with - * some arbitrary number. - */ - *addr = 50; - - /* This message is printed if no SIGSEGV */ - tst_resm(TFAIL, "process succeeds to refer unmapped " - "memory region"); - } else { - tst_resm(TPASS, "call succeeded"); - } - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - } /* End for TEST_LOOPING */ - - /* exit with return code appropriate for results */ - tst_exit(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * - * Set up signal handler to catch SIGSEGV. - * Get system page size, create a temporary file for reading/writing, - * write one byte data into it, map the open file for the specified - * map length. - */ -void -setup() -{ - size_t page_sz; /* system page size */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* call signal function to trap the signal generated */ - if (signal(SIGSEGV, sig_handler) == SIG_ERR) { - tst_brkm(TBROK, cleanup, "signal fails to catch signal"); - tst_exit(); - } - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Get the system page size */ - if ((page_sz = getpagesize()) < 0) { - tst_brkm(TBROK, cleanup, - "getpagesize() fails to get system page size"); - tst_exit(); - } - - /* - * Get the length of the open file to be mapped into process - * address space. - */ - map_len = 3 * page_sz; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666)) < 0) { - tst_brkm(TBROK, cleanup, "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - tst_exit(); - } - - /* - * move the file pointer to maplength position from the beginning - * of the file. - */ - if (lseek(fildes, map_len, SEEK_SET) == -1) { - tst_brkm(TBROK, cleanup, "lseek() fails on %s, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - tst_exit(); - } - - /* Write one byte into temporary file */ - if (write(fildes, "a", 1) != 1) { - tst_brkm(TBROK, cleanup, "write() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - tst_exit(); - } - - /* - * map the open file 'TEMPFILE' from its beginning up to the maplength - * into the calling process's address space at the system choosen - * with read/write permissions to the the mapped region. - */ - addr = mmap(0, map_len, PROT_READ | PROT_WRITE, \ - MAP_FILE | MAP_SHARED, fildes, 0); - - /* check for the return value of mmap system call */ - if (addr == (char *)MAP_FAILED) { - tst_brkm(TBROK, cleanup, "mmap() Failed on %s, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - tst_exit(); - } -} - -/* - * sig_handler() - signal catching function. - * This function is used to trap the signal generated when tried to read or - * write to the memory mapped region which is already detached from the - * calling process address space. - * this function is invoked when SIGSEGV generated and it calls test - * cleanup function and exit the program. - */ -void -sig_handler() -{ - tst_resm(TPASS, "Functionality of munmap() successful"); - - /* Invoke test cleanup function and exit */ - cleanup(); - - /* exit with return code appropriate for results */ - tst_exit(); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Close the temporary file. - * Remove the temporary directory. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Close the temporary file */ - if (close(fildes) < 0) { - tst_brkm(TFAIL, NULL, "close() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } - - /* Remove the temporary directory and all files in it */ - tst_rmdir(); -} diff --git a/winsup/testsuite/winsup.api/ltp/munmap02.c b/winsup/testsuite/winsup.api/ltp/munmap02.c deleted file mode 100644 index 7345e73e0..000000000 --- a/winsup/testsuite/winsup.api/ltp/munmap02.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: munmap02 - * - * Test Description: - * Verify that, munmap call will succeed to unmap a mapped file or - * anonymous shared memory region from the calling process's address space - * if the region specified by the address and the length is part or all of - * the mapped region. - * - * Expected Result: - * munmap call should succeed to unmap a part or all of mapped region of a - * file or anonymous shared memory from the process's address space and it - * returns with a value 0, - * further reference to the unmapped region should result in a segmentation - * fault (SIGSEGV). - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * munmap01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMPFILE "mmapfile" - -const char *TCID="munmap02"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -size_t page_sz; /* system page size */ -char *addr; /* addr of memory mapped region */ -int fildes; /* file descriptor for tempfile */ -unsigned int map_len; /* length of the region to be mapped */ - -void setup(); /* Main setup function of test */ -void cleanup(void); /* cleanup function for the test */ -void sig_handler(); /* signal catching function */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *)NULL, NULL); - if (msg != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* Perform global setup for test */ - setup(); - - /* - * Call munmap to unmap the part of the mapped region of the - * temporary file from the address and length that is part of - * the mapped region. - */ - TEST(munmap(addr, map_len)); - - /* Check for the return value of munmap() */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "munmap() fails, errno=%d : %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Check whether further reference is possible - * to the unmapped memory region by writing - * to the first byte of region with - * some arbitrary number. - */ - *addr = 50; - - /* This message is printed if no SIGSEGV */ - tst_resm(TFAIL, "process succeeds to refer unmapped " - "memory region"); - } else { - tst_resm(TPASS, "call succeeded"); - } - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - } /* End for TEST_LOOPING */ - - /* exit with return code appropriate for results */ - tst_exit(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Setup signal handler to catch SIGSEGV. - * Get system page size, create a temporary file for reading/writing, - * write one byte data into it, map the open file for the specified - * map length. - */ -void -setup() -{ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* call signal function to trap the signal generated */ - if (signal(SIGSEGV, sig_handler) == SIG_ERR) { - tst_brkm(TBROK, cleanup, "signal fails to catch signal"); - tst_exit(); - } - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Get the system page size */ - if ((page_sz = getpagesize()) < 0) { - tst_brkm(TBROK, cleanup, - "getpagesize() fails to get system page size"); - tst_exit(); - } - - /* - * Get the length of the open file to be mapped into process - * address space. - */ - map_len = 3 * page_sz; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666)) < 0) { - tst_brkm(TBROK, cleanup, "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - tst_exit(); - } - - /* - * move the file pointer to maplength position from the beginning - * of the file. - */ - if (lseek(fildes, map_len, SEEK_SET) == -1) { - tst_brkm(TBROK, cleanup, "lseek() fails on %s, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - tst_exit(); - } - - /* Write one byte into temporary file */ - if (write(fildes, "a", 1) != 1) { - tst_brkm(TBROK, cleanup, "write() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - tst_exit(); - } - - /* - * map the open file 'TEMPFILE' from its beginning up to the maplength - * into the calling process's address space at the system choosen - * with read/write permissions to the the mapped region. - */ - addr = mmap(0, map_len, PROT_READ | PROT_WRITE, - MAP_FILE | MAP_SHARED, fildes, 0); - - /* check for the return value of mmap system call */ - if (addr == (char *)MAP_FAILED) { - tst_brkm(TBROK, cleanup, "mmap() Failed on %s, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - tst_exit(); - } - - /* - * increment the start address of the region at which the file is - * mapped to a maplength of 3 times the system page size by the value - * of system page size and decrement the maplength value by the value - * of system page size. - */ - addr = (char *)((long)addr + page_sz); - map_len = map_len - page_sz; -} - -/* - * void - * sig_handler() - signal catching function. - * This function is used to trap the signal generated when tried to read or - * write to the memory mapped region which is already detached from the - * calling process address space. - * this function is invoked when SIGSEGV generated and it calls test - * cleanup function and exit the program. - */ -void -sig_handler() -{ - tst_resm(TPASS, "Functionality of munmap() successful"); - - /* Invoke test cleanup function and exit */ - cleanup(); - - /* exit with return code appropriate for results */ - tst_exit(); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Unmap the portion of the region of the file left unmapped. - * Close the temporary file. - * Remove the temporary directory. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* - * get the start address and length of the portion of - * the mapped region of the file. - */ - addr = (char *)((long)addr - page_sz); - map_len = map_len - page_sz; - - /* unmap the portion of the region of the file left unmapped */ - if (munmap(addr, map_len) < 0) { - tst_brkm(TBROK, NULL, - "munmap() fails to unmap portion of mapped region"); - } - - /* Close the temporary file */ - if (close(fildes) < 0) { - tst_brkm(TBROK, NULL, "close() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } - - /* Remove the temporary directory and all files in it */ - tst_rmdir(); -} diff --git a/winsup/testsuite/winsup.api/ltp/nice05.c b/winsup/testsuite/winsup.api/ltp/nice05.c deleted file mode 100644 index 1246e7fbd..000000000 --- a/winsup/testsuite/winsup.api/ltp/nice05.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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/open02.c b/winsup/testsuite/winsup.api/ltp/open02.c deleted file mode 100644 index 594ab5b1c..000000000 --- a/winsup/testsuite/winsup.api/ltp/open02.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * open02.c - * - * DESCRIPTION - * Test if open without O_CREAT returns -1 if a file does not exist. - * - * ALGORITHM - * 1. open a new file without O_CREAT, test for return value of -1 - * - * USAGE: - * open02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ -#include -#include -#include -#include -#include -#include - -const char *TCID = "open02"; -int TST_TOTAL = 1; -extern int Tst_count; - -char pfilname[40] = ""; - -int exp_enos[] = {ENOENT, 0}; - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* - * parse standard command line options - */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); /* global setup for test */ - - TEST_EXP_ENOS(exp_enos); - - /* - * check looping state if -i option given on the command line - */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - Tst_count = 0; /* reset Tst_count while looping. */ - - TEST(open(pfilname, O_RDWR, 0444)); - - if (TEST_RETURN != -1) { - tst_resm(TFAIL, "opened non-existent file"); - continue; - } - - TEST_ERROR_LOG(TEST_ERRNO); - - if (TEST_ERRNO != ENOENT) { - tst_resm(TFAIL, "open(2) set invalid errno: " - "expected ENOENT, got %d", TEST_ERRNO); - } else { - tst_resm(TPASS, "open returned ENOENT"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup(void) -{ - umask(0); - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that options was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - sprintf(pfilname, "./open3.%d", getpid()); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at completion or - * premature exit. - */ -void -cleanup(void) -{ - /* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/open03.c b/winsup/testsuite/winsup.api/ltp/open03.c deleted file mode 100644 index 6a699bad1..000000000 --- a/winsup/testsuite/winsup.api/ltp/open03.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 466875f21..000000000 --- a/winsup/testsuite/winsup.api/ltp/pathconf01.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - * 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 -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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; -const char *path = "/tmp"; - -struct pathconf_args -{ - const 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 */ - const 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 -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/pipe01.c b/winsup/testsuite/winsup.api/ltp/pipe01.c deleted file mode 100644 index cc01cc988..000000000 --- a/winsup/testsuite/winsup.api/ltp/pipe01.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * pipe01.c - * - * DESCRIPTION - * Testcase to check the basic functionality of the pipe(2) syscall: - * Check that both ends of the pipe (both file descriptors) are - * available to a process opening the pipe. - * - * ALGORITHM - * Write a string of characters down a pipe; read the string from the - * other file descriptor. Test passes if both can be done, as reported - * by the number of characters written and read. - * - * USAGE: - * pipe01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * RESTRICITONS - * NONE - */ -#include -#include "test.h" -#include "usctest.h" - -const char *TCID = "pipe01"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - int fildes[2]; /* fds for pipe read and write */ - char wrbuf[BUFSIZ], rebuf[BUFSIZ]; - int red, written; /* no. of chars read/written to pipe */ - int greater, length; - char *strcpy(); - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(pipe(fildes)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "pipe() failed unexpectedly - errno %d", - TEST_ERRNO); - continue; - } - - if (STD_FUNCTIONAL_TEST) { - - strcpy(wrbuf, "abcdefghijklmnopqrstuvwxyz"); - length = strlen(wrbuf); - - if ((written = write(fildes[1], wrbuf, length)) == -1) { - tst_brkm(TBROK, cleanup, "write() failed"); - } - - if ((written < 0) || (written > 26)) { - tst_resm(TFAIL, "Condition #1 test failed"); - continue; - } - - if ((red = read(fildes[0], rebuf, written)) == -1) { - tst_brkm(TBROK, cleanup, "read() failed"); - } - - if ((red < 0) || (red > written)) { - tst_resm(TFAIL, "Condition #2 test failed"); - continue; - } - - /* are the strings written and read equal */ - if ((greater = memcmp(rebuf, wrbuf, red)) != 0) { - tst_resm(TFAIL, "Condition #3 test failed"); - continue; - } - tst_resm(TPASS, "pipe() functionality is correct"); - } else { - tst_resm(TPASS, "call succeeded"); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; -} - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/pipe08.c b/winsup/testsuite/winsup.api/ltp/pipe08.c deleted file mode 100644 index 70d61dab8..000000000 --- a/winsup/testsuite/winsup.api/ltp/pipe08.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * pipe08.c - * - * DESCRIPTION - * Check that a SIGPIPE signal is generated when a write is - * attempted on an empty pipe. - * - * ALGORITHM - * 1. Write to a pipe after closing the read side. - * 2. Check for the signal SIGPIPE to be received. - * - * USAGE: - * pipe08 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * USAGE - * pipe08 - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ -#include -#include -#include "test.h" -#include "usctest.h" - -const char *TCID = "pipe08"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); -void sighandler(int); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - int pipefd[2]; /* fds for pipe read/write */ - char wrbuf[BUFSIZ]; - int written, length; - int close_stat; /* exit status of close(read fd) */ - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - if (!STD_FUNCTIONAL_TEST) { - tst_resm(TWARN, "-f option should not be used"); - } - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(pipe(pipefd)); - - if (TEST_RETURN != 0) { - tst_resm(TFAIL, "call failed unexpectedly"); - continue; - } - - if ((close_stat = close(pipefd[0])) == -1) { - tst_brkm(TBROK, cleanup, "close of read side failed"); - } - - strcpy(wrbuf, "abcdefghijklmnopqrstuvwxyz\0"); - length = strlen(wrbuf); - - /* - * the SIGPIPE signal will be caught here or else - * the program will dump core when the signal is - * sent - */ - written = write(pipefd[1], wrbuf, length); - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * sighandler - catch signals and look for SIGPIPE - */ -void -sighandler(int sig) -{ - if (sig != SIGPIPE) { - tst_resm(TFAIL, "expected SIGPIPE, got %d", sig); - } else { - tst_resm(TPASS, "got expected SIGPIPE signal"); - } -} - -/* - * setup() - performs all ONE TIME setup for this test. - */ -void -setup() -{ - /* capture signals */ - tst_sig(NOFORK, sighandler, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; -} - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/pipe09.c b/winsup/testsuite/winsup.api/ltp/pipe09.c deleted file mode 100644 index eb21bb601..000000000 --- a/winsup/testsuite/winsup.api/ltp/pipe09.c +++ /dev/null @@ -1,230 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * pipe09.c - * - * DESCRIPTION - * Check that two processes can use the same pipe at the same time. - * - * ALGORITHM - * 1. Open a pipe - * 2. Fork a child which writes to the pipe - * 3. Fork another child which writes a different character to the pipe - * 4. Have the parent read from the pipe - * 5. It should get the characters from both children. - * - * USAGE: - * pipe09 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ -#include -#include -#include -#include "test.h" -#include "usctest.h" - -#define PIPEWRTCNT 100 /* must be an even number */ - -const char *TCID = "pipe09"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - int i, red, wtstatus; - int pipefd[2]; /* fds for pipe read/write */ - char rebuf[BUFSIZ]; - int Acnt = 0, Bcnt = 0; /* count 'A' and 'B' */ - int fork_1, fork_2; /* ret values in parent */ - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(pipe(pipefd)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "pipe() call failed"); - continue; - } - - if (!STD_FUNCTIONAL_TEST) { - tst_resm(TWARN, "-f option should not be used"); - tst_resm(TPASS, "call succeeded"); - continue; - } - - if ((fork_1 = fork()) == -1) { - tst_brkm(TBROK, cleanup, "fork() #1 failed"); - /*NOTREACHED*/ - } - - if (fork_1 == 0) { /* 1st child */ - if (close(pipefd[0]) != 0) { - tst_resm(TWARN, "pipefd[0] close failed, " - "errno = %d", errno); - exit(1); - } - - for (i = 0; i < PIPEWRTCNT / 2; ++i) { - if (write(pipefd[1], "A", 1) != 1) { - tst_resm(TWARN, "write to pipe failed"); - exit(1); - } - } - exit(0); - } - - /* parent */ - - waitpid(fork_1, &wtstatus, 0); - if (WEXITSTATUS(wtstatus) != 0) { - tst_brkm(TBROK, cleanup, "problem detected in child, " - "wait status %d, errno = %d", wtstatus, errno); - } - - if ((fork_2 = fork()) == -1) { - tst_brkm(TBROK, cleanup, "fork() #2 failed"); - /*NOTREACHED*/ - } - - if (fork_2 == 0) { /* 2nd child */ - if (close(pipefd[0]) != 0) { - tst_resm(TWARN, "pipefd[0] close " - "failed, errno = %d", errno); - exit(1); - } - - for (i = 0; i < PIPEWRTCNT / 2; ++i) { - if (write(pipefd[1], "B", 1) != 1) { - tst_resm(TWARN, "write to pipe failed"); - exit(1); - } - } - exit(0); - } - - /* parent */ - - waitpid(fork_2, &wtstatus, 0); - if (WEXITSTATUS(wtstatus) != 0) { - tst_brkm(TBROK, cleanup, "problem detected in child, " - "wait status %d, errno = %d", wtstatus, errno); - } - - if (close(pipefd[1]) != 0) { - tst_brkm(TBROK, cleanup, "pipefd[1] close failed, " - "errno = %d", errno); - /*NOTREACHED*/ - } - - while ((red = read(pipefd[0], rebuf, 100)) > 0) { - for (i = 0; i < red; i++) { - if (rebuf[i] == 'A') { - Acnt++; - continue; - } - if (rebuf[i] == 'B') { - Bcnt++; - continue; - } - tst_resm(TFAIL, "got bogus '%c' character", - rebuf[i]); - break; - } - } - - if (red == -1) { - tst_brkm(TBROK, cleanup, "Failure reading pipefd pipe, " - "errno = %d", errno); - } - - if (Bcnt == Acnt && Bcnt == (PIPEWRTCNT / 2)) { - tst_resm(TPASS, "functionality appears to be correct"); - } else { - tst_resm(TFAIL, "functionality is not correct - Acnt " - "= %d, Bcnt = %d", Acnt, Bcnt); - } - - /* clean up things in case we are looping */ - Acnt = Bcnt = 0; - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; -} - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/pipe10.c b/winsup/testsuite/winsup.api/ltp/pipe10.c deleted file mode 100644 index 52ac5d94e..000000000 --- a/winsup/testsuite/winsup.api/ltp/pipe10.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * pipe10.c - * - * DESCRIPTION - * Check that parent can open a pipe and have a child read from it - * - * ALGORITHM - * Parent opens pipe, child reads. Passes if child can read all the - * characters written by the parent. - * - * USAGE: - * pipe10 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ -#include -#include -#include -#include - -const char *TCID = "pipe10"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - int fd[2]; /* fds for pipe read/write */ - char wrbuf[BUFSIZ], rebuf[BUFSIZ]; - int red, written; /* no of chars read and */ - /* written to pipe */ - int length, greater, forkstat; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(pipe(fd)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "pipe creation failed"); - continue; - } - - if (!STD_FUNCTIONAL_TEST) { - tst_resm(TPASS, "call succeeded"); - continue; - } - - strcpy(wrbuf, "abcdefghijklmnopqrstuvwxyz\0"); - length = strlen(wrbuf); - - written = write(fd[1], wrbuf, length); - - /* did write write at least some chars */ - if ((written < 0) || (written > length)) { - tst_brkm(TBROK, cleanup, "write to pipe failed"); - } - - forkstat = fork(); - - if (forkstat == -1) { - tst_brkm(TBROK, cleanup, "fork() failed"); - /*NOTREACHED*/ - } - - if (forkstat == 0) { /* child */ - red = read(fd[0], rebuf, written); - - /* did read , get at least some chars */ - if ((red < 0) || (red > written)) { - tst_brkm(TBROK, cleanup, "read pipe failed"); - } - - greater = memcmp(rebuf, wrbuf, red); - - /* are the strings written and read equal */ - if (greater == 0) { - tst_resm(TPASS, "functionality is correct"); - } else { - tst_resm(TFAIL, "read & write strings do " - "not match"); - } - } else { /* parent */ - /* let the child carry on */ - exit(0); - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; -} - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/pipe11.c b/winsup/testsuite/winsup.api/ltp/pipe11.c deleted file mode 100644 index 558e70a96..000000000 --- a/winsup/testsuite/winsup.api/ltp/pipe11.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * pipe11.c - * - * DESCRIPTION - * Check if many children can read what is written to a pipe by the - * parent. - * - * ALGORITHM - * 1. Open a pipe and write to it - * 2. Fork a large number of children - * 3. Have the children read the pipe and check how many characters - * each got - * - * USAGE: - * pipe11 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ -#include -#include -#include -#include "test.h" -#include "usctest.h" - -const char *TCID = "pipe11"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -#define NUMCHILD 50 -#define NCPERCHILD 50 -char rawchars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; -int kidid; -int numchild; /* no of children to fork */ -int ncperchild; /* no of chars child should read */ -int szcharbuf; /* size of char buf */ -int pipewrcnt; /* chars written to pipe */ -char *wrbuf, *rdbuf; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - int fd[2]; /* fds for pipe read/write */ - int i; - int fork_ret, status; - int nread, written; /* no of chars read and written */ - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(pipe(fd)); - - if (TEST_RETURN != 0) { - tst_resm(TFAIL, "pipe creation failed"); - continue; - } - - if (!STD_FUNCTIONAL_TEST) { - tst_resm(TPASS, "call succeeded"); - continue; - } - - written = write(fd[1], wrbuf, szcharbuf); - if (written != szcharbuf) { - tst_brkm(TBROK, cleanup, "write to pipe failed"); - } - -refork: - ++kidid; - fork_ret = fork(); - - if (fork_ret < 0) { - tst_brkm(TBROK, cleanup, "fork() failed"); - /*NOTREACHED*/ - } - - if ((fork_ret != 0) && (fork_ret != -1) && (kidid < numchild)) { - goto refork; - } - - if (fork_ret == 0) { /* child */ - if (close(fd[1])) { - tst_resm(TINFO, "child %d " "could not close " - "pipe", kidid); - exit(0); - } - nread = read(fd[0], rdbuf, ncperchild); - if (nread == ncperchild) { - tst_resm(TINFO, "child %d " "got %d chars", - kidid, nread); - exit(0); - } else { - tst_resm(TFAIL, "child %d did not receive " - "expected no of characters, got %d " - "characters", kidid, nread); - exit(1); - } - } - - /* parent */ - sleep(5); - tst_resm(TINFO, "There are %d children to wait for", kidid); - for (i = 1; i <= kidid; ++i) { - wait(&status); - if (status == 0) { - tst_resm(TPASS, "child %d exitted successfully", - i); - } else { - tst_resm(TFAIL, "child %d exitted with bad " - "status", i); - } - } - } - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test. - */ -void -setup() -{ - int i, j; - - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - numchild = NUMCHILD; - ncperchild = NCPERCHILD; - - kidid = 0; - - /* allocate read and write buffers */ - szcharbuf = numchild * ncperchild; - - /* make sure pipe write doesn't block */ - if (szcharbuf == PIPE_BUF) { - /* adjust number of characters per child */ - ncperchild = szcharbuf / numchild; - } - - if ((wrbuf = (char *)malloc(szcharbuf)) == (char *)0) { - tst_brkm(TBROK, cleanup, "malloc failed"); - /*NOTREACHED*/ - } - - if ((rdbuf = (char *)malloc(szcharbuf)) == (char *)0) { - tst_brkm(TBROK, cleanup, "malloc of rdbuf failed"); - /*NOTREACHED*/ - } - - /* initialize wrbuf */ - j = 0; - for (i = 0; i < szcharbuf; ) { - wrbuf[i++] = rawchars[j++]; - if (j >= (int)sizeof(rawchars)) { - j = 0; - } - } -} - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/poll01.c b/winsup/testsuite/winsup.api/ltp/poll01.c deleted file mode 100644 index 704b738a2..000000000 --- a/winsup/testsuite/winsup.api/ltp/poll01.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: poll01 - * - * Test Description: - * Verify that valid open file descriptor must be provided to poll() to - * succeed. - * - * Expected Result: - * poll should return the correct values when an valid file descriptor is - * provided. - * - * Algorithm: - * 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) - * Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * - * Usage: - * poll01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * None. - */ -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define BUF_SIZE 512 - -const char *TCID="poll01"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -int fildes[2]; /* file descriptors of the pipe. */ -struct pollfd fds[1]; /* struct. for poll() */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - pid_t cpid; /* child process id */ - char write_buf[] = "Testing\0"; /* buffer string for write */ - char read_buf[BUF_SIZE]; /* buffer for read-end of pipe */ - int status; /* exit status of child process */ - int rval; - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *)NULL, NULL); - if (msg != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* Reset Tst_count in case we are looping. */ - Tst_count = 0; - - /* - * Call poll() with the TEST macro. - */ - TEST(poll(fds, 1, -1)); - - /* check return code of poll() */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "poll() failed on write, errno=%d" - " : %s", TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - - /* write the message to the pipe */ - if (write(fildes[1], write_buf, strlen(write_buf)) - < (int)strlen(write_buf)) { - tst_brkm(TBROK, cleanup, "write() failed on write " - "to pipe, error:%d", errno); - } - - /* Fork child process */ - if ((cpid = fork()) == -1) { - tst_brkm(TBROK, cleanup, "fork() failed"); - } - - if (cpid == 0) { /* Child process */ - /* - * close writing end of pipe and read from - * the pipe - */ - if (close(fildes[1]) == -1) { - tst_brkm(TFAIL, NULL, "close() failed on write " - "endof pipe, errno:%d", errno); - exit(1); - } - - /* - * Set poll() data structures to check - * if data is present on read - */ - fds[0].fd = fildes[0]; - fds[0].events = POLLIN; - - /* - * If data are present, then read the data. If poll() - * and read() return expected values, then the - * functionality of poll() is correct. - */ - rval = (poll(fds, 1, -1)); - - if (rval == -1) { - tst_resm(TFAIL, "poll() failed on read - " - "errno=%d : %s", - TEST_ERRNO, strerror(errno)); - exit(1); - } - - /* Read data from read end of pipe */ - if (read(fildes[0], read_buf, sizeof(read_buf)) != - (int)strlen(write_buf)) { - tst_brkm(TFAIL, NULL, "read() failed - " - "error:%d", errno); - exit(1); - } - - /* Now, do the actual comparision */ - if (memcmp(read_buf, write_buf, strlen(write_buf))) { - tst_resm(TFAIL, "Data from reading pipe " - "are different"); - exit(1); - } - - /* Everything is fine, exit normally */ - exit(0); - } else { /* Parent process */ - /* Wait for child to complete execution */ - wait(&status); - - if (WEXITSTATUS(status) == 1) { - tst_resm(TFAIL, "child exited abnormally"); - } else { - tst_resm(TPASS, - "Functionality of poll() successful"); - } - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * Creat read/write pipe using pipe(). - * Set poll data structures to check writing to the pipe. - */ -void -setup() -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* Creat read/write pipe */ - if (pipe(fildes) < 0) { - tst_brkm(TBROK, tst_exit, - "pipe() failed to create interprocess channel"); - } - - /* Set poll data structures */ - fds[0].fd = fildes[1]; - fds[0].events = POLLOUT; -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * close read end of pipe if still open. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* close read end of pipe if still open */ - if (close(fildes[0]) < 0) { - tst_brkm(TFAIL, NULL, "close() failed on read-end of pipe, " - "errno:%d", errno); - } - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/read01.c b/winsup/testsuite/winsup.api/ltp/read01.c deleted file mode 100644 index 332b939a7..000000000 --- a/winsup/testsuite/winsup.api/ltp/read01.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * 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 : read01 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Basic test for read(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.) read(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 read(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 - * read(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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -/* - * Set READ_BLOCK_SIZE to the block size of the system. - */ -#ifdef linux -#define READ_BLOCK_SIZE DEV_BSIZE -#else -#ifdef __CYGWIN__ -#define READ_BLOCK_SIZE S_BLKSIZE -#else -#define READ_BLOCK_SIZE BSIZE -#endif -#endif - -extern void setup(); -extern void cleanup(); - - - -const char *TCID="read01"; /* 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, i; -int offset=0; -char *s; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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 (write(fd, s, READ_BLOCK_SIZE) == -1) { - tst_brkm(TBROK, cleanup, - "write(%s, %s, %d) Failed, errno=%d : %s", - fname, s, READ_BLOCK_SIZE, errno, strerror(errno)); - } - offset+=READ_BLOCK_SIZE; - if (lseek(fd, (long)(offset-READ_BLOCK_SIZE), 0) == -1) { - tst_brkm(TBROK, cleanup, - "lseek(%s, %ld, 0) Failed, errno=%d : %s", - fname, (long)(offset-READ_BLOCK_SIZE), errno, strerror(errno)); - } - /* - * Call read(2) - */ - TEST(read(fd, s, READ_BLOCK_SIZE)); - - /* check return code */ - if ( TEST_RETURN == -1 ) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, "read(fd, s, READ_BLOCK_SIZE) 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, "read(pfds) 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; - - if ((s = malloc(READ_BLOCK_SIZE)) == NULL) { - tst_brkm(TBROK, cleanup, - "malloc(%d) Failed, errno=%d : %s", - READ_BLOCK_SIZE, errno, strerror(errno)); - } - (void) memset(s, '*', READ_BLOCK_SIZE); - for (i=0; i < READ_BLOCK_SIZE; i++) { - if ( s[i] != '*' ) { - tst_brkm(TBROK, cleanup, - "File Data pattern not setup correctly : expected * at s[%d] : found %c", - i, s[i]); - } - } - 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/read04.c b/winsup/testsuite/winsup.api/ltp/read04.c deleted file mode 100644 index c976cd6a4..000000000 --- a/winsup/testsuite/winsup.api/ltp/read04.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * read01.c - * - * DESCRIPTION - * Testcase to check if read returns the number of bytes read correctly. - * - * ALGORITHM - * Create a file and write some bytes out to it. - * Attempt to read more than written. - * Check the return count, and the read buffer. The read buffer should be - * same as the write buffer. - * - * USAGE: - * read01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None - */ -#include -#include -#include "test.h" -#include "usctest.h" - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID = "read01"; -int TST_TOTAL = 1; -extern int Tst_count; - -#define TST_SIZE 26 /* could also do strlen(palfa) */ -char fname[255]; -char palfa[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; -int fild; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - int rfild; - char prbuf[BUFSIZ]; - - /* - * parse standard options - */ - if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){ - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); /* global setup for test */ - - /* check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - Tst_count = 0; /* reset Tst_count while looping */ - - if ((rfild = open(fname, O_RDONLY)) == -1) { - tst_brkm(TBROK, cleanup, "can't open for reading"); - /*NOTREACHED*/ - } - TEST(read(rfild, prbuf, BUFSIZ)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "call failed unexpectedly"); - continue; - } - - if (STD_FUNCTIONAL_TEST) { - if (TEST_RETURN != TST_SIZE) { - tst_resm(TFAIL, "Bad read count - got %d - " - "expected %d", TEST_RETURN, TST_SIZE); - continue; - } - if (memcmp(palfa, prbuf, TST_SIZE) != 0) { - tst_resm(TFAIL, "read buffer not equal " - "to write buffer"); - continue; - } - tst_resm(TPASS, "functionality of read() is correct"); - } else { - tst_resm(TPASS, "call succeeded"); - } - if (close(rfild) == -1) { - tst_brkm(TBROK, cleanup, "close() failed"); - /*NOTREACHED*/ - } - } - cleanup(); - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - umask(0); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - sprintf(fname,"tfile_%d",getpid()); - - if ((fild = creat(fname, 0777)) == -1) { - tst_brkm(TBROK, cleanup, "creat(%s, 0777) Failed, errno = %d" - " : %s", fname, errno, strerror(errno)); - /*NOTREACHED*/ - } - if (write(fild, palfa, TST_SIZE) != TST_SIZE) { - tst_brkm(TBROK, cleanup, "can't write to Xread"); - /*NOTREACHED*/ - } - close (fild); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at completion or - * premature exit. - */ -void -cleanup(void) -{ - /* - * 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 */ - unlink(fname); - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/readdir01.c b/winsup/testsuite/winsup.api/ltp/readdir01.c deleted file mode 100644 index c77e90680..000000000 --- a/winsup/testsuite/winsup.api/ltp/readdir01.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * 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 : readdir01 - * - * EXECUTED BY : anyone - * - * TEST TITLE : write multiple files and try to find them with readdir - * - * TEST CASE TOTAL : - * - * WALL CLOCK TIME : - * - * CPU TYPES : ALL - * - * AUTHOR : Nate Straz - * - * CO-PILOT : - * - * DATE STARTED : 02/16/2001 - * - * INITIAL RELEASE : Linux 2.4.x - * - * TEST CASES - * - * 1.) Create n files and check that readdir() finds n files - * - * 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 readdir(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 - * readdir(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 -#include -#include -#include -#include -#include -#include - /* test.h and usctest.h are the two header files that are required by the - * quickhit package. They contain function and macro declarations which you - * can use in your test programs - */ -#include "test.h" -#include "usctest.h" - - /* The setup and cleanup functions are basic parts of a test case. These - * steps are usually put in separate functions for clarity. The help function - * is only needed when you are adding new command line options. - */ -void setup(); -void help(); -void cleanup(void) __attribute__((noreturn)); - -const char *TCID="readdir01"; /* 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 "readdirfile" - -char Basename[255]; -char Fname[255]; -int Nfiles=0; - -/* To add command line options you need to declare a structure to pass to - * parse_opts(). options is the structure used in this example. The format is - * the string that should be added to optstring in getopt(3), an integer that - * will be used as a flag if the option is given, and a pointer to a string that - * should receive the optarg parameter from getopt(3). Here we add a -N - * option. Long options are not supported at this time. - */ -char *Nfilearg; -int Nflag=0; - -/* for test specific parse_opts options */ -option_t options[] = { - { "N:", &Nflag, &Nfilearg }, /* -N #files */ - { NULL, NULL, NULL } -}; - -/*********************************************************************** - * Main - ***********************************************************************/ -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - int cnt; - int nfiles, fd; - char fname[255]; - DIR *test_dir; - struct dirent *dptr; - - Tst_nobuf=1; - - /*************************************************************** - * parse standard options - ***************************************************************/ - /* start off by parsing the command line options. We provide a function - * that understands many common options to control looping. If you are not - * adding any new options, pass NULL in place of options and &help. - */ - if ( (msg=parse_opts(ac, av, options, &help)) ) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - } - - if ( Nflag ) { - if (sscanf(Nfilearg, "%i", &Nfiles) != 1 ) { - tst_brkm(TBROK, NULL, "--N option arg is not a number"); - tst_exit(); - } - } - - /*************************************************************** - * perform global setup for test - ***************************************************************/ - /* Next you should run a setup routine to make sure your environment is - * sane. - */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /*************************************************************** - * check looping state - ***************************************************************/ - /* TEST_LOOPING() is a macro that will make sure the test continues - * looping according to the standard command line args. - */ - for (lc=0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping. */ - Tst_count=0; - - if ( Nfiles ) - nfiles = Nfiles; - else - /* min of 10 links and max of a 100 links */ - nfiles = (lc%90)+10; - - /* create a bunch of files to look at */ - for(cnt=0; cnt < nfiles; cnt++) { - - sprintf(fname, "%s%d", Basename, cnt); - 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, "hello\n", 6) < 0) { - tst_brkm(TBROK, cleanup, - "write(%s, \"hello\\n\", 6) Failed, errno=%d : %s", fname, errno, strerror(errno)); - } else if (close(fd) < 0) { - tst_res(TWARN, "close(%s) Failed, errno=%d : %s", - fname, errno, strerror(errno)); - } - } - - if ((test_dir = opendir(".")) == NULL) { - tst_resm(TFAIL, "opendir(\".\") Failed, errno=%d : %s", - errno, strerror(errno)); - } else { - /* count the entries we find to see if any are missing */ - cnt = 0; - errno = 0; - while ( (dptr = readdir(test_dir)) ) { - if (strcmp(dptr->d_name, ".") && strcmp(dptr->d_name, "..")) - cnt++; - } - - if (errno != 0) { - tst_resm(TFAIL, "readir(test_dir) Failed on try %d, errno=%d : %s", - cnt, errno, strerror(errno)); - } - if (cnt == nfiles) { - tst_resm(TPASS, "found all %d that were created", nfiles); - } else if (cnt > nfiles) { - tst_resm(TFAIL, "found more files than were created"); - tst_resm(TINFO, "created: %d, found: %d", nfiles, cnt); - } else { - tst_resm(TFAIL, "found less files than were created"); - tst_resm(TINFO, "created: %d, found: %d", nfiles, cnt); - } - } - - /* Here we clean up after the test case so we can do another iteration. - */ - for(cnt=0; cnt < nfiles; cnt++) { - - sprintf(fname, "%s%d", Basename, cnt); - - if (unlink(fname) == -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 - ***************************************************************/ -/* The custom help() function is really simple. Just write your help message to - * standard out. Your help function will be called after the standard options - * have been printed - */ -void -help() -{ - printf(" -N #files : create #files files every iteration\n"); -} - -/*************************************************************** - * setup() - performs all ONE TIME setup for this test. - ***************************************************************/ -void -setup() -{ - /* You will want to enable some signal handling so you can capture - * unexpected signals like SIGSEGV. - */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - /* One cavet that hasn't been fixed yet. TEST_PAUSE contains the code to - * fork the test with the -c option. You want to make sure you do this - * before you create your temporary directory. - */ - TEST_PAUSE; - - /* If you are doing any file work, you should use a temporary directory. We - * provide tst_tmpdir() which will create a uniquely named temporary - * directory and cd into it. You can now create files in the current - * directory without worrying. - */ - tst_tmpdir(); - - sprintf(Basename, "%s_%d.", BASENAME, getpid()); -} - -/*************************************************************** - * 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 you use a temporary directory, you need to be sure you remove it. Use - * tst_rmdir() to do it automatically. - */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/readlink01.c b/winsup/testsuite/winsup.api/ltp/readlink01.c deleted file mode 100644 index 744fff02a..000000000 --- a/winsup/testsuite/winsup.api/ltp/readlink01.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name : readlink01 - * - * Test Description : - * Verify that, readlink will succeed to read the contents of the symbolic - * link created the process. - * - * Expected Result: - * readlink() should return the contents of symbolic link path in the buffer - * on success. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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) - * Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * readlink01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * This test should be run by 'non-super-user' only. - * - */ -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TESTFILE "testfile" -#define SYMFILE "slink_file" -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define MAX_SIZE 256 - -const char *TCID="readlink01"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -int exp_val; /* strlen of testfile */ - -void setup(); /* Setup function for the test */ -void cleanup(void) __attribute__((noreturn)); /* Cleanup function for the test */ - -int -main(int ac, char **av) -{ - char buffer[MAX_SIZE]; /* temporary buffer to hold symlink contents*/ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *)NULL, NULL); - if (msg != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call readlink(2) to read the contents of - * symlink into a buffer. - */ - TEST(readlink(SYMFILE, buffer, sizeof(buffer))); - - /* Check return code of readlink(2) */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "readlink() on %s failed, errno=%d : %s" - , SYMFILE, TEST_ERRNO, strerror(TEST_ERRNO)); - continue; - } - - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Compare the return value of readlink() - * with the expected value which is the - * strlen() of testfile. - */ - if (TEST_RETURN == exp_val) { - /* Check for the contents of buffer */ - if (memcmp(buffer, TESTFILE, exp_val) != 0) { - tst_resm(TFAIL, "Pathname %s and buffer" - " contents %s differ", - TESTFILE, buffer); - } else { - tst_resm(TPASS, "readlink() " - "functionality on '%s' is " - "correct", SYMFILE); - } - } else { - tst_resm(TFAIL, "readlink() return value %d " - "does't match, Expected %d", - TEST_RETURN, exp_val); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and close it - * Create a symbolic link of testfile. - */ -void -setup() -{ - int fd; /* file handle for testfile */ - - /* make sure test is not being run as root */ - if (0 == geteuid()) { - tst_brkm(TBROK, tst_exit, "Must not run test as root"); - } - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - if ((fd = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - } - - if (close(fd) == -1) { - tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } - - /* Create a symlink of testfile under temporary directory */ - if (symlink(TESTFILE, SYMFILE) < 0) { - tst_brkm(TBROK, cleanup, - "symlink(%s, %s) failed, errno=%d : %s", - TESTFILE, SYMFILE, errno, strerror(errno)); - } - - /* Get the strlen of testfile */ - exp_val = strlen(TESTFILE); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * - * Remove the test directory and testfile created in the setup. - */ -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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/readlink02.c b/winsup/testsuite/winsup.api/ltp/readlink02.c deleted file mode 100644 index 4ef6ffa11..000000000 --- a/winsup/testsuite/winsup.api/ltp/readlink02.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/readlink03.c b/winsup/testsuite/winsup.api/ltp/readlink03.c deleted file mode 100644 index 41cf4bbe9..000000000 --- a/winsup/testsuite/winsup.api/ltp/readlink03.c +++ /dev/null @@ -1,360 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name : readlink03 - * - * Test Description : - * Verify that, - * 1) readlink(2) returns -1 and sets errno to EACCES if search/write - * permission is denied in the directory where the symbolic link - * resides. - * 2) readlink(2) returns -1 and sets errno to EINVAL if the buffer size - * is not positive. - * 3) readlink(2) returns -1 and sets errno to EINVAL if the specified - * file is not a symbolic link file. - * 4) readlink(2) returns -1 and sets errno to ENAMETOOLONG if the - * pathname component of symbolic link is too long (ie, > PATH_MAX). - * 5) readlink(2) returns -1 and sets errno to ENOENT if the component of - * symbolic link points to an empty string. - * - * Expected Result: - * readlink() should fail with return value -1 and set expected errno. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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) - * if errno set == expected errno - * Issue sys call fails with expected return value and errno. - * Otherwise, - * Issue sys call fails with unexpected errno. - * Otherwise, - * Issue sys call returns unexpected value. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory(s)/file(s) created. - * - * Usage: - * readlink03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS: - * This test should be executed by 'non-super-user' only. - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define MODE_RWX S_IRWXU | S_IRWXG | S_IRWXO -#define FILE_MODE S_IRUSR | S_IRGRP | S_IROTH -#define DIR_TEMP "testdir_1" -#define TESTFILE "testfile" -#define TEST_FILE1 "testdir_1/tfile_1" -#define SYM_FILE1 "testdir_1/sfile_1" -#define TEST_FILE2 "tfile_2" -#define SYM_FILE2 "sfile_2" -#define MAX_SIZE 256 - -const char *TCID="readlink03"; /* 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[]={EACCES, EINVAL, ENAMETOOLONG, ENOENT, 0}; - -int no_setup(); -int setup1(); /* setup function to test symlink for EACCES */ -int setup2(); /* setup function to test symlink for EEXIST */ -int lpath_setup(); /* setup function to test chmod for ENAMETOOLONG */ - -char Longpathname[PATH_MAX+2]; - -struct test_case_t { /* test case struct. to hold ref. test cond's*/ - const char *link; - const char *desc; - int exp_errno; - size_t buf_siz; - int (*setupfunc)(); -} Test_cases[] = { -#ifndef __CYGWIN__ - { SYM_FILE1, "No Search permissions to process", EACCES, 1, setup1 }, - { SYM_FILE2, "Buffer size is not positive", EINVAL, -1, setup2 }, - { TEST_FILE2, "File is not symbolic link", EINVAL, 1, no_setup }, -#else - { TEST_FILE2, "File is not symbolic link", EINVAL, 1, setup2 }, -#endif - { Longpathname, "Symlink path too long", ENAMETOOLONG, 1, lpath_setup }, - { "", "Symlink Pathname is empty", ENOENT, 1, no_setup }, - { NULL, NULL, 0, 0, no_setup } -}; - -extern void setup(); /* Setup function for the test */ -void cleanup() __attribute__((noreturn));/* Cleanup function for the test */ - -int -main(int ac, char **av) -{ - char buffer[MAX_SIZE]; /* temporary buffer to hold symlink contents*/ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - const char *sym_file; /* symbolic link file name */ - const char *test_desc; /* test specific error message */ - int i; /* counter to test different test conditions */ - size_t buf_size; /* size of buffer for readlink */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *)NULL, NULL); - if (msg != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* - * Invoke setup function to call individual test setup functions - * to simulate test conditions. - */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - for (i = 0; Test_cases[i].desc != NULL; i++) { - sym_file = Test_cases[i].link; - test_desc = Test_cases[i].desc; - buf_size = Test_cases[i].buf_siz; - - if (buf_size == 1) { - buf_size = sizeof(buffer); - } - - /* - * Call readlink(2) to test different test conditions. - * verify that it fails with -1 return value and sets - * appropriate errno. - */ - TEST(readlink(sym_file, buffer, buf_size)); - - /* Check return code of readlink(2) */ - if (TEST_RETURN != -1) { - tst_resm(TFAIL, "readlink() returned %d, " - "expected -1, errno:%d", TEST_RETURN, - Test_cases[i].exp_errno); - continue; - } - - TEST_ERROR_LOG(TEST_ERRNO); - - if (TEST_ERRNO == Test_cases[i].exp_errno) { - tst_resm(TPASS, "readlink(), %s, returned " - "errno %d", test_desc, TEST_ERRNO); - tst_resm(TPASS, "readlink(), %s, returned " - "errno %d", test_desc, TEST_ERRNO); - } else { - tst_resm(TFAIL, "readlink() failed, %s, " - "errno=%d, expected errno=%d", - test_desc, TEST_ERRNO, - Test_cases[i].exp_errno); - } - } /* End of TEST CASE LOOPING. */ - } /* End for TEST_LOOPING */ - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - - /*NOTREACHED*/ -} /* End main */ - -/* - * setup() - performs all ONE TIME setup for this test. - * - * Create a temporary directory and change directory to it. - * Call test specific setup functions. - */ -void -setup() -{ - int i; - - /* make sure test is not being run as root */ - if (0 == geteuid()) { - tst_brkm(TBROK, tst_exit, "Must not run test as root"); - } - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* call individual setup functions */ - for (i = 0; Test_cases[i].desc != NULL; i++) { - Test_cases[i].setupfunc(); - } -} - -/* - * no_setup() - Some test conditions for readlink(2) do not any setup. - */ -int -no_setup() -{ - return 0; -} - -/* - * setup1() - setup function for a test condition for which readlink(2) - * returns -1 and sets errno to EACCES. - * - * Create a test directory under temporary directory and create a test file - * under this directory with mode "0666" permissions. - * Create a symlink of testfile under test directory. - * Modify the mode permissions on test directory such that process will not - * have search permissions on test directory. - */ -int -setup1() -{ - int fd; /* file handle for testfile */ - - if (mkdir(DIR_TEMP, MODE_RWX) < 0) { - tst_brkm(TBROK, cleanup, "mkdir(2) of %s failed", DIR_TEMP); - } - - if ((fd = open(TEST_FILE1, O_RDWR|O_CREAT, 0666)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, 0666) failed, errno=%d : %s", - TEST_FILE1, errno, strerror(errno)); - } - if (close(fd) == -1) { - tst_brkm(TBROK, cleanup, "close(%s) failed, errno=%d : %s", - TEST_FILE1, errno, strerror(errno)); - } - - /* Creat a symbolic link of testfile under test directory */ - if (symlink(TEST_FILE1, SYM_FILE1) < 0) { - tst_brkm(TBROK, cleanup, "symlink of %s failed", TEST_FILE1); - } - - /* Modify mode permissions on test directory */ - if (chmod(DIR_TEMP, FILE_MODE) < 0) { - tst_brkm(TBROK, cleanup, "chmod(2) of %s failed", DIR_TEMP); - } - return 0; -} - -/* - * setup2() - setup function for a test condition for which readlink(2) - * returns -1 and sets errno to EINVAL. - * - * Create a testfile under temporary directory and create a symlink - * file of it. - */ -int -setup2() -{ - int fd; /* file handle for testfile */ - - /* Creat a testfile and close it */ - if ((fd = open(TEST_FILE2, O_RDWR|O_CREAT, 0666)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, 0666) failed, errno=%d : %s", - TEST_FILE2, errno, strerror(errno)); - } - if (close(fd) == -1) { - tst_brkm(TBROK, cleanup, "close(%s) failed, errno=%d : %s", - TEST_FILE2, errno, strerror(errno)); - } - - /* Creat a symlink of testfile created above */ - if (symlink(TEST_FILE2, SYM_FILE2) < 0) { - tst_brkm(TBROK, cleanup, "symlink() failed to create %s in " - "setup2, error=%d", SYM_FILE2, errno); - } - return 0; -} - -/* - * lpath_setup() - setup to create a node with a name length exceeding - * the MAX. length of PATH_MAX. - */ -int -lpath_setup() -{ - int i; /* counter variable */ - - for (i = 0; i <= (PATH_MAX + 1); i++) { - Longpathname[i] = 'a'; - } - return 0; -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * - * Restore the mode permissions on test directory. - * Remove the temporary directory created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Restore mode permissions on test directory created in setup2() */ - if (chmod(DIR_TEMP, MODE_RWX) < 0) { - tst_brkm(TBROK, NULL, "chmod(2) of %s failed", DIR_TEMP); - } - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/rename01.c b/winsup/testsuite/winsup.api/ltp/rename01.c deleted file mode 100644 index 14ae1f245..000000000 --- a/winsup/testsuite/winsup.api/ltp/rename01.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * rename01 - * - * DESCRIPTION - * This test will verify the rename(2) syscall basic functionality. - * Verify rename() works when the "new" file or directory does not exist. - * - * ALGORITHM - * Setup: - * Setup signal handling. - * Create temporary directory. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * 1. "old" is plain file, new does not exists - * create the "old" file, make sure the "new" file - * dose not exist - * rename the "old" to the "new" file - * verify the "new" file points to the "old" file - * verify the "old" file does not exist - * - * 2. "old" is a directory,"new" does not exists - * create the "old" directory, make sure "new" - * dose not exist - * rename the "old" to the "new" - * verify the "new" points to the "old" - * verify the "old" does not exist - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * USAGE - * rename01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None. - */ -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); -extern void do_file_setup(char *); - -const char *TCID="rename01"; /* Test program identifier. */ -int TST_TOTAL=2; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -char fname[255], mname[255]; -char fdir[255], mdir[255]; -struct stat buf1; -dev_t f_olddev, d_olddev; -ino_t f_oldino, d_oldino; - -struct test_case_t { - const char *name1; - const char *name2; - const char *desc; - dev_t *olddev; - ino_t *oldino; -} TC[] = { - /* comment goes here */ - {fname, mname, "file", &f_olddev, &f_oldino}, - - /* comment goes here */ - {fdir, mdir, "directory", &d_olddev, &d_oldino} -}; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - int i; - - /* - * parse standard options - */ - if ((msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* - * perform global setup for test - */ - setup(); - - /* - * check looping state if -i option given - */ - for (lc=0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping. */ - Tst_count=0; - - /* loop through the test cases */ - for (i=0; i -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); -void do_file_setup(); - - - -const 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 */ - const 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/rename08.c b/winsup/testsuite/winsup.api/ltp/rename08.c deleted file mode 100644 index 0788ddc98..000000000 --- a/winsup/testsuite/winsup.api/ltp/rename08.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * rename08 - * - * DESCRIPTION - * This test will verify that rename(2) syscall failed in EFAULT - * - * ALGORITHM - * Setup: - * Setup signal handling. - * Create temporary directory. - * Pause for SIGUSR1 if option specified. - * Create a valid file to use in the rename() call. - * - * Test: - * Loop if the proper options are given. - * 1. "old" is a valid file, newpath points to address - * outside allocated address space - * rename the "old" to the "new" file - * verify rename() failed with error EFAULT - * - * 2. "old" points to address outside allocated address space - * ,"new" is a valid file - * rename the "old" to the "new" - * verify rename() failed with error EFAULT - * - * 3. oldpath and newpath are all NULL - * try to rename NULL to NULL - * verify rename() failed with error EFAULT - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created.* - * USAGE - * rename08 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None. - */ -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); -extern void do_file_setup(char *); - -const char *TCID="rename08"; /* 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[]={EFAULT, 0}; /* List must end with 0 */ - -int fd; -char fname[255]; - -struct test_case_t { - char *fd; - char *fd2; - int error; -} TC[] = { - /* "new" file is invalid - EFAULT */ - {fname, (char *)-1, EFAULT}, - - /* "old" file is invalid - EFAULT */ - {(char *)-1, fname, EFAULT}, - - /* both files are NULL - EFAULT */ - {NULL, NULL, EFAULT} -}; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - int i; - - /* - * parse standard options - */ - if ((msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* - * perform global setup for test - */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* - * check looping state if -i option given - */ - for (lc=0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping. */ - Tst_count=0; - - /* loop through the test cases */ - for (i = 0; i < TST_TOTAL; i++) { - - TEST(rename(TC[i].fd, TC[i].fd2)); - - if (TEST_RETURN != -1) { - tst_resm(TFAIL, "call succeeded unexpectedly"); - continue; - } - - TEST_ERROR_LOG(TEST_ERRNO); - - if (TEST_ERRNO == TC[i].error) { - tst_resm(TPASS, "expected failure - " - "errno = %d : %s", TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - tst_resm(TFAIL, "unexpected error - %d : %s - " - "expected %d", TEST_ERRNO, - strerror(TEST_ERRNO), TC[i].error); - } - } - } /* End for TEST_LOOPING */ - - /* - * cleanup and exit - */ - cleanup(); - /*NOTREACHED*/ -} - -/* - * 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; - - /* Create a temporary directory and make it current. */ - tst_tmpdir(); - - sprintf(fname,"./tfile_%d",getpid()); - - do_file_setup(fname); -} - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/rename10.c b/winsup/testsuite/winsup.api/ltp/rename10.c deleted file mode 100644 index 438ef3725..000000000 --- a/winsup/testsuite/winsup.api/ltp/rename10.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * rename10 - * - * DESCRIPTION - * This test will verify that rename(2) syscall fails with ENAMETOOLONG - * and ENOENT - * - * ALGORITHM - * Setup: - * Setup signal handling. - * Create temporary directory. - * Pause for SIGUSR1 if option specified. - * create the "old" file - * - * Test: - * Loop if the proper options are given. - * 1. rename the "old" to the "new" file - * verify rename() failed with error ENAMETOOLONG - * - * 2. "new" path contains a directory that does not exist - * rename the "old" to the "new" - * verify rename() failed with error ENOENT - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created.* - * - * USAGE - * rename10 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None. - */ -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); -extern void do_file_setup(char *); - -const char *TCID="rename10"; /* Test program identifier. */ -int TST_TOTAL=2; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -char badmname[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyz"; - -int exp_enos[]={ENAMETOOLONG, ENOENT, 0}; /* List must end with 0 */ - -int fd; -char fname[255], mname[255]; -char mdir[255]; - -struct test_case_t { - char *fd1; - char *fd2; - int error; -} TC[] = { - /* badmname is too long for a file name - ENAMETOOLONG */ - {fname, badmname, ENAMETOOLONG}, - - /* mname contains a directory component which does not exist - ENOENT */ - {fname, mname, ENOENT} -}; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - int i; - - /* - * parse standard options - */ - if ((msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* - * perform global setup for test - */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* - * check looping state if -i option given - */ - for (lc=0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping. */ - Tst_count=0; - - /* loop through the test cases */ - for (i=0; i < TST_TOTAL; i++) { - - TEST(rename(TC[i].fd1, TC[i].fd2)); - - if (TEST_RETURN != -1) { - tst_resm(TFAIL, "call succeeded unexpectedly"); - continue; - } - - TEST_ERROR_LOG(TEST_ERRNO); - - if (TEST_ERRNO == TC[i].error) { - tst_resm(TPASS, "expected failure - " - "errno = %d : %s", TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - tst_resm(TFAIL, "unexpected error - %d : %s - " - "expected %d", TEST_ERRNO, - strerror(TEST_ERRNO), TC[i].error); - } - } - } /* End for TEST_LOOPING */ - - /* - * cleanup and exit - */ - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; - - /* Create a temporary directory and make it current. */ - tst_tmpdir(); - - sprintf(fname,"./tfile_%d",getpid()); - sprintf(mdir,"./rndir_%d",getpid()); - sprintf(mname,"%s/rnfile_%d",mdir,getpid()); - - do_file_setup(fname); -} - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/rmdir01.c b/winsup/testsuite/winsup.api/ltp/rmdir01.c deleted file mode 100644 index 1d41f1c13..000000000 --- a/winsup/testsuite/winsup.api/ltp/rmdir01.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * rmdir01 - * - * DESCRIPTION - * This test will verify that rmdir(2) syscall basic functionality. - * verify rmdir(2) returns a value of 0 and the directory being - * removed - * - * ALGORITHM - * Setup: - * Setup signal handling. - * Create temporary directory. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * make a directory tstdir - * call rmdir(tstdir), check the return value - * verify the directory tstdir does not exists. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created.* - * USAGE - * rmdir01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None. - */ -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup() __attribute__((noreturn)); - -#define PERMS 0777 - -const char *TCID="rmdir01"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -char tstdir [100]; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - struct stat buf; - - /* - * parse standard options - */ - if ((msg=parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL) { - tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg); - } - - /* - * perform global setup for test - */ - setup(); - - /* - * check looping state if -i option given - */ - for (lc=0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * TEST rmdir() base functionality - */ - - /* Initialize the test directory name */ - - /* create a directory */ - if ( mkdir(tstdir, PERMS) == -1 ) { - tst_brkm(TBROK, cleanup, "mkdir(%s, %#o) Failed", - tstdir, PERMS); - /*NOTREACHED*/ - } - /* call rmdir using TEST macro */ - - TEST(rmdir(tstdir)); - - if (TEST_RETURN == -1 ) { - tst_resm(TFAIL, "rmdir(%s) Failed", tstdir); - continue; - } - - if (STD_FUNCTIONAL_TEST) { - /* check whether tstdir been removed */ - if (stat(tstdir, &buf) != -1) { - tst_resm(TFAIL, "directory %s still exists", - tstdir); - continue; - } else { - tst_resm(TPASS, "directory has been removed"); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - - } /* End for TEST_LOOPING */ - - /* - * cleanup and exit - */ - cleanup(); - - /*NOTREACHED*/ -} - -/* - * 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; - - /* Create a temporary directory and make it current. */ - tst_tmpdir(); - - sprintf(tstdir,"./tstdir_%d",getpid()); -} - -/* - * 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(); -} diff --git a/winsup/testsuite/winsup.api/ltp/rmdir04.c b/winsup/testsuite/winsup.api/ltp/rmdir04.c deleted file mode 100644 index ece6a9ff4..000000000 --- a/winsup/testsuite/winsup.api/ltp/rmdir04.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * 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 -#include -#include - -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/rmdir05.c b/winsup/testsuite/winsup.api/ltp/rmdir05.c deleted file mode 100644 index ff19b3a81..000000000 --- a/winsup/testsuite/winsup.api/ltp/rmdir05.c +++ /dev/null @@ -1,447 +0,0 @@ -/* - * 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 : rmdir05 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Functionality Tests for rmdir(2) - * - * PARENT DOCUMENT : rmstds02 - * - * TEST CASE TOTAL : 6 - * - * WALL CLOCK TIME : 2 - * - * CPU TYPES : ALL - * - * AUTHOR : Bill Branum - * - * CO-PILOT : Steve Shaw - * - * DATE STARTED : 4/23/92 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * rmdir(2) test for errno(s) EINVAL, EMLINK, EFAULT - * - * INPUT SPECIFICATIONS - * The standard options for system call tests are accepted. - * (See the parse_opts(3) man page). - * - * ENVIRONMENTAL NEEDS - * No run-time environmental needs. - * - * DETAILED DESCRIPTION - * Verify that rmdir(2) returns a value of -1 and sets errno - * to indicate the error. - * - * Setup: - * Setup signal handling. - * Create a temporary directory and make it current. - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - -extern char *get_high_address(); - -const char *TCID="rmdir05"; /* Test program identifier. */ -int TST_TOTAL=6; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines. */ -struct stat stat_buf; /* Stat buffer used for verification. */ -char dir_name[256]; /* Array to hold directory name. */ - - -int -main(int argc, char **argv) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - - /*************************************************************** - * parse standard options - ***************************************************************/ - if ( (msg=parse_opts(argc, argv, (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: 1 - * path points to the current directory - */ - - /* Call rmdir(2) */ - TEST(rmdir(".")); - - /* 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 defined(sgi) - if (TEST_ERRNO == EINVAL) { -#elif defined(linux) || defined (__CYGWIN__) - if (TEST_ERRNO & (EBUSY | ENOTEMPTY)) { -#endif - - /* For functionality tests, verify that the - * directory wasn't removed. - */ - if (stat(".",&stat_buf) == -1){ - tst_resm(TFAIL,"rmdir(\".\") removed the current working directory when it should have failed."); - } else { - tst_resm(TPASS,"rmdir(\".\") failed to remove the current working directory. Returned %d : %s",TEST_ERRNO,strerror(TEST_ERRNO)); - } - } else { -#if defined(sgi) - tst_resm(TFAIL,"rmdir(\".\") failed with errno %d : %s but expected %d (EINVAL)",TEST_ERRNO,strerror(TEST_ERRNO),EINVAL); -#elif defined(linux) || defined (__CYGWIN__) - tst_resm(TFAIL,"rmdir(\".\") failed with errno %d : %s but expected %d (EBUSY)",TEST_ERRNO,strerror(TEST_ERRNO),EBUSY); -#endif - } - } else { - tst_resm(TFAIL,"rmdir(\".\") succeeded unexpectedly."); - } - } - - - /* - * TEST CASE: 2 - * path points to the "." (dot) entry of a directory - */ -#if defined(linux) || defined (__CYGWIN__) - tst_resm(TCONF, "rmdir on \"dir/.\" supported on Linux"); -#elif defined(sgi) - /* Call rmdir(2) */ - TEST(rmdir("dir1/.")); - - /* 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 == EINVAL) { - - /* For functionality tests, verify that the - * directory wasn't removed. - */ - if (stat("dir1/.",&stat_buf) == -1){ - tst_resm(TFAIL,"rmdir(\"dir1/.\") removed the \".\" entry of a directory when it should have failed."); - } else { - tst_resm(TPASS,"rmdir(\"dir1/.\") failed to remove the \".\" entry of a directory. Returned %d : %s",TEST_ERRNO,strerror(TEST_ERRNO)); - } - } else { - tst_resm(TFAIL,"rmdir(\"dir1/.\") failed with errno %d : %s but expected %d (EINVAL)",TEST_ERRNO,strerror(TEST_ERRNO),EINVAL); - } - } else { - tst_resm(TFAIL,"rmdir(\"dir1/.\") - path points to the \".\" entry of a directory succeeded unexpectedly."); - } - } -#endif - -#if defined(sgi) - /* - * TEST CASE: 3 - * the directory has been linked - */ - tst_resm(TCONF, "linked directories not valid on IRIX"); -#elif defined(linux) - tst_resm(TCONF, "linked directories test not implemented on Linux"); -#elif defined(CRAY) - - - /* Call rmdir(2) */ - TEST(rmdir("dir2")); - - /* 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 == EMLINK) { - /* For functionality tests, verify that the directory wasn't - * removed. - */ - if (stat("dir2",&stat_buf) == -1){ - tst_resm(TFAIL,"rmdir(\"dir2\") removed a directory with multiple links when it should have failed."); - } else { - tst_resm(TPASS,"rmdir(\"dir2\") failed to remove a directory with multiple links. Returned %d : %s",TEST_ERRNO,strerror(TEST_ERRNO)); - } - } else { - tst_resm(TFAIL,"rmdir(\"dir2\") failed with errno %d : %s but expected %d (EMLINK)",TEST_ERRNO,strerror(TEST_ERRNO),EMLINK); - } - } else { - tst_resm(TFAIL,"rmdir(\"dir2\") - the directory has been linked succeeded unexpectedly."); - } - } -#endif /* linux */ - - - /* - * TEST CASE: 4 - * path argument points below the minimum allocated address space - */ - - - /* Call rmdir(2) */ - TEST(rmdir((char *)-1)); - - /* 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,"rmdir() - path argument points below the minimum allocated address space failed as expected with errno %d : %s",TEST_ERRNO,strerror(TEST_ERRNO)); - } else { - tst_resm(TFAIL,"rmdir() - path argument points below the minimum allocated address space failed with errno %d : %s but expected %d (EFAULT)",TEST_ERRNO,strerror(TEST_ERRNO),EFAULT); - } - } else { - tst_resm(TFAIL,"rmdir() - path argument points below the minimum allocated address space succeeded unexpectedly."); - } - } - - /* - * TEST CASE: 5 - * path argument points above the maximum allocated address space - */ - - - /* Call rmdir(2) */ - TEST(rmdir( get_high_address())); - - /* 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,"rmdir() - path argument points above the maximum allocated address space failed as expected with errno %d : %s",TEST_ERRNO,strerror(TEST_ERRNO)); - } else { - tst_resm(TFAIL,"rmdir() - path argument points above the maximum allocated address space failed with errno %d : %s but expected %d (EFAULT)",TEST_ERRNO,strerror(TEST_ERRNO),EFAULT); - } - } else { - tst_resm(TFAIL,"rmdir() - path argument points above the maximum allocated address space succeeded unexpectedly."); - } - } - - /* - * TEST CASE: 6 - * able to remove a directory - */ - - /* Create a directory. */ - if (mkdir(dir_name,0777) != 0){ - tst_brkm(TBROK,cleanup,"mkdir(\"%s\") failed with errno %d : %s",dir_name,errno,strerror(errno)); - } - - /* Call rmdir(2) */ - TEST(rmdir(dir_name)); - - /* check return code */ - if ( TEST_RETURN == -1 ) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL,"rmdir(\"%s\") failed when it should have passed. Returned %d : %s",dir_name,TEST_ERRNO,strerror(TEST_ERRNO)); - } else { - - /*************************************************************** - * only perform functional verification if flag set (-f not given) - ***************************************************************/ - if ( STD_FUNCTIONAL_TEST ) { - - /* Verify the directory was removed. */ - if (stat(dir_name,&stat_buf) != 0){ - tst_resm(TPASS,"rmdir(\"%s\") removed the directory as expected.",dir_name); - } else { - tst_resm(TFAIL,"rmdir(\"%s\") returned a zero exit status but failed to remove the directory.",dir_name); - } - } - } - - } /* 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 make it current. */ - tst_tmpdir(); - - /* Create a directory. */ - if (mkdir("dir1",0777) == -1){ - tst_brkm(TBROK,cleanup,"mkdir() failed to create dir1."); - } - -#if defined(CRAY) - /* NOTE: linking directories is NOT valid on IRIX */ - - /* Create a directory that has multiple links to it. */ - if (mkdir("dir2",0777) == -1){ - tst_brkm(TBROK,cleanup,"mkdir() failed to create dir2."); - } else { - if (system("runcmd `get_attrib -A link` dir2 mlink_dir > link.out 2>&1") != 0){ - tst_brk(TBROK,"link.out",cleanup,"link failed to link dir2 and mlink_dir."); - } - } - -#endif - - /* Create a unique directory name. */ - sprintf(dir_name,"./dir_%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; - -#if defined(CRAY) - /* NOTE: setup was not done on IRIX */ - /* Unlink the directory. */ - if (system("runcmd `get_attrib -A unlink` dir2 > unlink.out 2>&1") != 0){ - tst_res(TWARN,"unlink.out","unlink failed to unlink dir2."); - } -#endif - - /* - * Remove the temporary directory. - */ - tst_rmdir(); - - /* - * Exit with a return value appropriate for the results. - */ - tst_exit(); - -} /* End cleanup() */ diff --git a/winsup/testsuite/winsup.api/ltp/sbrk01.c b/winsup/testsuite/winsup.api/ltp/sbrk01.c deleted file mode 100644 index 700fb6b17..000000000 --- a/winsup/testsuite/winsup.api/ltp/sbrk01.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * 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 : sbrk01 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Basic test for sbrk(2) - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 2 - * - * WALL CLOCK TIME : 1 - * - * CPU TYPES : ALL - * - * AUTHOR : William Roske - * - * CO-PILOT : Dave Fenner - * - * DATE STARTED : 06/05/92 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * - * 1.) sbrk(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 sbrk(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 - * sbrk(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 -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const char *TCID="sbrk01"; /* Test program identifier. */ -int TST_TOTAL=2; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -int Increment; /* Amount to make change size by */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - long tret; - - /*************************************************************** - * 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(0); - } - - /*************************************************************** - * perform global setup for test - ***************************************************************/ - setup(); - -#ifdef __CYGWIN__ - /* we need to initialize output buffer before first sbrk. - otherwise, when memory is freed bu second sbrk, fwrite will - fail */ - tst_resm(TINFO, "Entering test"); -#endif - - /*************************************************************** - * 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: - * Increase by 8192 bytes - */ - Increment = 8192; - - /* Call sbrk(2) */ -#if defined(sgi) - tret=(long)sbrk(Increment); /* Remove -64 IRIX compiler warning */ - TEST_ERRNO=errno; -#else - TEST(sbrk(Increment)); - tret=TEST_RETURN; -#endif - - /* check return code */ - if ( tret == -1 ) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, "sbrk - Increase by 8192 bytes 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, "sbrk - Increase by 8192 bytes returned %d", - tret); - } - } - - - /* - * TEST CASE: - * Decrease to original size - */ - Increment=(Increment * -1); - - /* Call sbrk(2) */ -#ifdef CRAY - TEST(sbrk(Increment)); - tret=TEST_RETURN; -#else - tret=(long)sbrk(Increment); - TEST_ERRNO=errno; -#endif - - /* check return code */ - if ( tret == -1 ) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, "sbrk - Decrease to original size 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, "sbrk - Decrease to original size returned %d", tret); - } - } - - - } /* 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/select01.c b/winsup/testsuite/winsup.api/ltp/select01.c deleted file mode 100644 index 3b81f93db..000000000 --- a/winsup/testsuite/winsup.api/ltp/select01.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * 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 -#include -#include /* For open system call parameters. */ -#include -#include -#include -#include - -#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 -#endif - -#include "test.h" -#include "usctest.h" - -#define FILENAME "select01" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - -const 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 */ - const 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/select02.c b/winsup/testsuite/winsup.api/ltp/select02.c deleted file mode 100644 index 935f4b273..000000000 --- a/winsup/testsuite/winsup.api/ltp/select02.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * 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 : select02 - * - * EXECUTED BY : anyone - * - * TEST TITLE : select of system pipe fds - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 1 - * - * WALL CLOCK TIME : 1 - * - * CPU TYPES : ALL - * - * AUTHOR : Richard Logan - * - * CO-PILOT : Glen Overby - * - * DATE STARTED : 02/24/93 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * - * 1.) select(2) to fd of system pipe 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. - * - * 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 -#include -#include /* For open system call parameters. */ -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - -const char *TCID="select02"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -int Fd[2]; -fd_set saved_Readfds, saved_Writefds; -fd_set Readfds, Writefds; - -/*********************************************************************** - * MAIN - ***********************************************************************/ -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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); - - Readfds = saved_Readfds; - Writefds = saved_Writefds; - - /* Call the system call being tested. */ - - TEST(select(5, &Readfds, &Writefds, 0, &timeout)); - - /* check return code */ - if ( TEST_RETURN == -1 ) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, - "%d select(5, &Readfds, &Writefds, 0, &timeout) failed, errno=%d\n", - lc, errno); - } else { - - /*************************************************************** - * only perform functional verification if flag set (-f not given) - ***************************************************************/ - if ( STD_FUNCTIONAL_TEST ) { - /* Perform functional verification here */ - tst_resm(TPASS, - "select(5, &Readfds, &Writefds, 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 (pipe(Fd) == -1 ) { - tst_brkm(TBROK, cleanup, "pipe(&Fd) failed, errno=%d", errno); - } - - /* - * Initializing and assigning the standard output file descriptor to - * fd_set for select. - */ - - FD_ZERO(&saved_Readfds); - FD_ZERO(&saved_Writefds); - FD_SET(Fd[0], &saved_Readfds); - FD_SET(Fd[1], &saved_Writefds); - - /* 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 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/select03.c b/winsup/testsuite/winsup.api/ltp/select03.c deleted file mode 100644 index 225ef19a7..000000000 --- a/winsup/testsuite/winsup.api/ltp/select03.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * 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 : select03 - * - * EXECUTED BY : anyone - * - * TEST TITLE : select of fd of a named-pipe (FIFO) - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 1 - * - * WALL CLOCK TIME : 1 - * - * CPU TYPES : ALL - * - * AUTHOR : Richard Logan - * - * CO-PILOT : Glen Overby - * - * DATE STARTED : 02/24/93 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * - * 1.) select(2) of fd of a named-pipe (FIFO) with no I/O and small timeout value - * - * 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. - * - * 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 -#include -#include /* For open system call parameters. */ -#include -#include -#include -#include -#include - - -#include "test.h" -#include "usctest.h" - -#define FILENAME "select03" - -extern void setup(); -extern void cleanup(); - -const char *TCID="select03"; /* 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 saved_Readfds, saved_Writefds; -fd_set Readfds, Writefds; - - -/*********************************************************************** - * MAIN - ***********************************************************************/ -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const 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); - - Readfds = saved_Readfds; - Writefds = saved_Writefds; - - /* Call the system call being tested. */ - - TEST(select(5, &Readfds, &Writefds, 0, &timeout)); - - /* check return code */ - if ( TEST_RETURN == -1 ) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, - "%d select(5, &Readfds, &Writefds, 0, &timeout) failed errno=%d\n", - lc, errno); - } else { - - /*************************************************************** - * only perform functional verification if flag set (-f not given) - ***************************************************************/ - if ( STD_FUNCTIONAL_TEST ) { - /* Perform functional verification here */ - tst_resm(TPASS, - "select(5, &Readfds, &Writefds, 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(); - - - /* make and open FIFO */ - if ( mkfifo(FILENAME, 0777) == -1 ) { - tst_brkm(TBROK, cleanup, "mkfifo(%s, 0777) failed, errno=%d", - FILENAME, errno); - } - - if ((Fd=open(FILENAME, O_RDWR)) == -1 ) { - tst_brkm(TBROK, cleanup, "open(%s, O_RDWR) failed, errno=%d", - FILENAME, errno); - } - - /* - * Initializing and assigning the standard output file descriptor to - * fd_set for select. - */ - - FD_ZERO(&saved_Readfds); - FD_ZERO(&saved_Writefds); - FD_SET(Fd, &saved_Readfds); - FD_SET(Fd, &saved_Writefds); - - /* 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 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 deleted file mode 100644 index a75e88a1d..000000000 --- a/winsup/testsuite/winsup.api/ltp/setgid01.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * 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 -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index ee1c54b63..000000000 --- a/winsup/testsuite/winsup.api/ltp/setgroups01.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * 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 -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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 deleted file mode 100644 index 0835c66a3..000000000 --- a/winsup/testsuite/winsup.api/ltp/setpgid01.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup() __attribute__ ((noreturn)); - -const 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 */ - const 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 deleted file mode 100644 index e4251f04e..000000000 --- a/winsup/testsuite/winsup.api/ltp/setregid01.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * 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 -#include -#include - -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 05467c80f..000000000 --- a/winsup/testsuite/winsup.api/ltp/setreuid01.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * 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 -#include -#include - -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 37e18fd51..000000000 --- a/winsup/testsuite/winsup.api/ltp/setuid01.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * 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 -#include -#include - -#include - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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 deleted file mode 100644 index ee55ae19b..000000000 --- a/winsup/testsuite/winsup.api/ltp/setuid02.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * 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 -#include -#include - -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/signal03.c b/winsup/testsuite/winsup.api/ltp/signal03.c deleted file mode 100644 index 2a0923ca2..000000000 --- a/winsup/testsuite/winsup.api/ltp/signal03.c +++ /dev/null @@ -1,663 +0,0 @@ -/* - * 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. Eagan, Minnesota - * - * TEST IDENTIFIER : signal03 Boundary value and other invalid value checking - * of signal setup and signal sending. - * - * PARENT DOCUMENT : sgntds01 Signal System Call - * - * AUTHOR : Dave Baumgartner - * : Rewrote 12/92 by Richard Logan - * - * CO-PILOT : Barrie Kletscher - * - * DATE STARTED : 10/17/85 - * - * TEST ITEMS - * - * 1. SIGKILL can not be set to be caught, errno:EINVAL (POSIX). - * 2. SIGKILL can not be caught. - * 3. SIGKILL can not be set to be ignored, errno:EINVAL (POSIX). - * 4. SIGKILL can not be ignored. - * 5. SIGKILL can not be reset to default, errno:EINVAL (POSIX. - * - * ENVIRONMENTAL NEEDS - * - * NONE - * - * SPECIAL PROCEDURAL REQUIREMENTS - * - * None - * - * INTERCASE DEPENDENCIES - * - * 2 depends on 1 and 4 on 3. - * - * DETAILED DESCRIPTION - * - * main() - * Call catch_test to test setup and catching of SIGKILL. - * - * - * Call ignore_test to test setup and ignoring of SIGKILL. - * - * - * Call sigdfl_test to test setting SIGKILL to default. - * - * * END OF MAIN * - * - * - * catch_test() - * - * fork a child - * if this is the parent - * sleep to let child start. - * send sig to child. - * wait for the child to terminate. - * - * if the termination status of the child equals the signal sent to it - * Test item 1 PASSED the child was killed. - * else if status equals the exit value of SIG_CAUGHT - * Test item 2 FAILED sig was caught. - * else - * Test item 2 FAILED because the child was not killed - * but sig was not caught either. - * - * else this the child - * set exit_val to SIG_NOT_CAUGHT. - * set to catch sig, where the interrupt routine just sets - * exit_val to SIG_CAUGHT. - * - * If the return value and errno, after trying to set to catch sig, - * do not indicate that an error has occurred. - * Test item 1 FAILED bad return, return value:X, errno:X. - * else - * Test item 1 PASSED sig was not set to be caught. - * - * pause until the parent sends a signal. - * The child should be killed by the signal but if not exit - * with exit_val. - * - * * End of catch_test. * - * - * - * ignore_test() - * - * fork a child - * if this is the parent - * sleep to let child start. - * send SIGKILL to child. - * wait for the child to terminate. - * - * if the termination status of the child equals SIGKILL - * Test item 4 PASSED the child was killed. - * else if the status equals the exit value of SIG_IGNORED - * Test item 4 FAILED SIGKILL was ignored. - * - * else this the child - * - * If the return value and errno, after trying to set to ignore SIGKILL, - * do not indicate that an error has occurred. - * Test item 3 FAILED bad return, return value:X, errno:X. - * else - * Test item 3 PASSED SIGKILL was not set to be ignored. - * - * pause until the parent sends SIGKILL. - * The child should be killed by the signal but if not exit - * with SIG_IGNORED. - * - * * End of ignore_test. * - * - * - * sigdfl_test() - * - * If the return value and errno, after trying to set to SIGKILL to default, - * do not indicate that an error has occurred. - * Test item 5 FAILED bad return, return value:X, errno:X. - * else - * Test item 5 PASSED SIGKILL was not set to default. - * - * * End of sigdfl_test. * - * - * BUGS/NOTES - * Since the system call under test is executed in the child, no - * timings on this system call will be reported. - * -***********************************************************************************/ - -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); -void do_test(); -void sigdfl_test(); -void update_timings(); - -#if defined(linux) -# define SIG_PF sig_t /* This might need to be sighandler_t on some systems */ -#elif defined(__CYGWIN__) -typedef void (*sighandler_t) (int); -#define SIG_PF sighandler_t -#endif - -#define SIG_CAUGHT 1 -#define SIG_NOT_CAUGHT 0 -#define SIG_IGNORED 5 -#define TIMED_OUT 99 - -#define TIMEOUT 20 - -#define GO_FLAG 1 -#define ERROR_FLAG 2 -#define PASS_FLAG 3 -#define FAIL_FLAG 4 - -#define IGNORE_TEST 1 -#define CATCH_TEST 2 - -#define MAXMESG 150 /* The Maximum message that can be created. */ - -int exit_val; /* Global variable, used to tell whether the */ - /* child exited instead of being killed. */ -extern int errno; /* errno holds the error value returned by */ - /* a system call. */ -char mesg[MAXMESG]; /* Holds messages to pass to tst_res. */ - -struct ipc_t { - int status; - char mesg[MAXMESG]; - struct tblock timings; -} Ipc_info; - -const char *TCID = "signal03"; -int TST_TOTAL = 5; -extern int Tst_count; /* count of test items completed */ - -int Pid; /* Return value from fork. */ - -long Tret; - -/*********************************************************************** - * M A I N - ***********************************************************************/ -int -main(argc, argv) -int argc; -char **argv; -{ - int lc; - const char *msg; - - /*************************************************************** - * parse standard options - ***************************************************************/ - if ( (msg=parse_opts(argc, argv, (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; - - errno=-4; - - /* - * Call catch_test to test setup and catching of SIGKILL. - */ - (void) do_test(CATCH_TEST, Tst_count); - - /* - * Call ignore_test to test setup and ignoring of SIGKILL. - */ - (void) do_test(IGNORE_TEST, Tst_count); - - /* - * Call sigdfl_test to test setting SIGKILL to default. - */ - (void) sigdfl_test(); - - } - - cleanup(); - - return 0; -} /*End of main*/ - -/*********************************************************************** - * - ***********************************************************************/ -void -do_test(test_case, tst_count) -int test_case; -int tst_count; -{ - int term_stat; /* Termination status of the child returned to */ - /* the parent. */ - char string[30]; - int fd1[2]; /* ipc */ - int rd_sz; /* size of read */ - void p_timeout_handler(); - void c_timeout_handler(); - void catchsig(); - - Tst_count = tst_count; - - /* - * Create a pipe of ipc - */ - if ( pipe(fd1) == -1 ) { - sprintf(mesg, - "pipe system call failed, Errno: %d, Error message: %s", - errno,strerror(errno)); - tst_resm(TBROK,mesg); - tst_resm(TBROK,mesg); - return; - } - - /* - * Cause the read to return 0 once EOF is encountered and the - * read to return -1 if pipe is empty. - */ - - if ( fcntl(fd1[0], F_SETFL, O_NONBLOCK) == -1 ) { - sprintf(mesg, "fcntl(fd1[0], F_SETFL, O_NONBLOCK) failed: errno=%d", - errno); - tst_resm(TBROK,mesg); - tst_resm(TBROK,mesg); - close(fd1[0]); - close(fd1[1]); - return; - } - - if ((Pid = fork()) > 0) { /* parent */ - - signal(SIGALRM, p_timeout_handler); - - alarm(TIMEOUT); - - close(fd1[1]); /* close write side */ - - /* - * Deal with child's messages. - * Only the GO_FLAG status will allow parent to - * go on. All pipe io will be in the ipc_t structure sizes - * to avoid reading part of next message. - */ - while ( 1 ) { - - while ( (rd_sz=read(fd1[0], (char *)&Ipc_info, sizeof(Ipc_info))) != 0 ) { - if ( rd_sz > 0 ) - break; /* read something */ - } - - if ( rd_sz == 0 ) { /* if EOF encountered */ - sprintf(mesg, "child's pipe is closed before 'go' message received"); - tst_resm(TBROK, Ipc_info.mesg); - tst_resm(TBROK, Ipc_info.mesg); - close(fd1[0]); - return; - } - - else if ( Ipc_info.status == GO_FLAG ) { - break; /* go on */ - } - else if ( Ipc_info.status == ERROR_FLAG ) { - tst_resm(TBROK, "From child: %s", Ipc_info.mesg); - tst_resm(TBROK, "From child: %s", Ipc_info.mesg); - close(fd1[0]); - return; - } - else if ( Ipc_info.status == PASS_FLAG ) { - - if ( STD_FUNCTIONAL_TEST ) - tst_resm(TPASS, "From child: %s", Ipc_info.mesg); - else - Tst_count++; - update_timings(Ipc_info.timings); - } - else if ( Ipc_info.status == FAIL_FLAG ) { - tst_resm(TFAIL, "From child: %s", Ipc_info.mesg); - update_timings(Ipc_info.timings); - } - else { - tst_resm(TINFO, "Unknown message from child: %s", mesg); - } - } - - /* - * Send the signal SIGKILL to the child. - */ - if (kill(Pid,SIGKILL) == -1) - { - /* - * The kill system call failed. - */ - sprintf(mesg, - "kill(Pid,SIGKILL) failed, Errno: %d, Error message: %s", - errno,strerror(errno)); - tst_resm(TBROK,mesg); - tst_resm(TBROK,mesg); - close(fd1[0]); - return; - } - - /* - * Wait for the child to terminate and check the termination status. - */ - if (wait(&term_stat) == -1) { - /* - * The wait system call failed. - */ - sprintf(mesg, - "Wait system call failed. Errno: %d, Error message: %s", - errno,strerror(errno)); - tst_resm(TBROK,mesg); - tst_resm(TBROK,mesg); - close(fd1[0]); - return; - } - else if ( STD_FUNCTIONAL_TEST ) { - if ((term_stat & 0377) == SIGKILL) { - /* - * The child was killed by the signal sent, - * which is correct. - */ - tst_resm(TPASS,"The child was killed by SIGKILL."); - } - else if ( (term_stat >> 8) == TIMED_OUT ) { - sprintf(mesg, "child exited with a timed out exit status"); - tst_resm(TBROK,mesg); - } - else { - if ((term_stat >> 8) == SIG_IGNORED && test_case == IGNORE_TEST ) { - sprintf(mesg, - "SIGKILL was ignored by child after sent by parent."); - } - else if ((term_stat >> 8) == SIG_CAUGHT && test_case == CATCH_TEST ) { - sprintf(mesg, - "SIGKILL was caught by child after sent by parent."); - } - else { - sprintf(mesg, - "Child's termination status is unexpected. Status: %d (%#o).", - term_stat, term_stat); - } - tst_resm(TFAIL, mesg); - } - } - else { - Tst_count++; /* increment test counter */ - } - close(fd1[0]); - - } /* End of parent. */ - else if (Pid == 0) { - /* - * This is the child. - * Set up to ignore/catch SIGKILL and check the return values. - */ - errno=0; - if ( test_case == IGNORE_TEST ) { - exit_val = SIG_IGNORED; - strcpy(string, "signal(SIGKILL, SIG_IGN)"); - - Tret=(long)signal(SIGKILL, SIG_IGN); - TEST_ERRNO=errno; - } - else { - exit_val = SIG_NOT_CAUGHT; - strcpy(string, "signal(SIGKILL, catchsig)"); - Tret=(long)signal(SIGKILL, catchsig); - TEST_ERRNO=errno; - } - Ipc_info.timings=tblock; - - if ( (SIG_PF)Tret == SIG_ERR ) { - if ( TEST_ERRNO == EINVAL ) { - sprintf(Ipc_info.mesg, "%s ret:%ld SIG_ERR (%ld) as expected", - string, Tret, (long)SIG_ERR); - Ipc_info.status = PASS_FLAG; - } - else { - sprintf(Ipc_info.mesg, - "%s ret:%ld, errno:%d expected ret:%ld, errno:%d", - string, Tret, TEST_ERRNO, (long)SIG_ERR, EINVAL); - Ipc_info.status = FAIL_FLAG; - } - - write(fd1[1], (char *)&Ipc_info, sizeof(Ipc_info)); - } - else { - /* - * The child was not allowed to set the signal to - * be ignored and errno was correct. - */ - sprintf(Ipc_info.mesg, - "%s ret:%ld, errno:%d expected ret:%ld, errno:%d", - string, Tret, TEST_ERRNO, (long)SIG_ERR, EINVAL); - Ipc_info.status = FAIL_FLAG; - write(fd1[1], (char *)&Ipc_info, sizeof(Ipc_info)); - } - - /* - * tell parent we are ready - setup by child is done - */ - Ipc_info.status = GO_FLAG; - write(fd1[1], (char *)&Ipc_info, sizeof(Ipc_info)); - - /* - * Set the alarm to wake up from the pause below if - * the parents signal is ignored. - */ - signal(SIGALRM, p_timeout_handler); - alarm(TIMEOUT); - - /* - * Pause until the parent sends a signal or until alarm is received. - */ - pause(); - - exit(exit_val); - - - } /* End of child. */ - else { - /* - * The fork system call failed. - */ - sprintf(mesg, - "Fork system call failed. Errno: %d, Error message: %s", - errno,strerror(errno)); - tst_resm(TBROK,mesg); - tst_resm(TBROK,mesg); - close(fd1[0]); - close(fd1[1]); - return; - } - -} /* End of do_test. */ - -/*********************************************************************** - * sigdfl_test - test for attempt to set SIGKILL to default - ***********************************************************************/ -void -sigdfl_test() -{ - /* - * Try to set SIGKILL to default and check the return values. - */ - errno=-4; - - Tret=(long)signal(SIGKILL,SIG_DFL); - TEST_RETURN=Tret; - TEST_ERRNO=errno; - - - if ( (SIG_PF)TEST_RETURN == SIG_ERR ) { - if ( STD_FUNCTIONAL_TEST ) { - if ( TEST_ERRNO != EINVAL ) { - sprintf(mesg, - "signal(SIGKILL,SIG_DFL) ret:%d, errno:%d expected ret:-1, errno:%d", - TEST_RETURN, TEST_ERRNO, EINVAL); - tst_resm(TFAIL, mesg); - } - else { - sprintf(mesg, - "signal(SIGKILL,SIG_DFL) ret:%d, errno:%d as expected.", - TEST_RETURN, TEST_ERRNO); - tst_resm(TPASS, mesg); - } - } - else - Tst_count++; - } - else { - sprintf(mesg, - "signal(SIGKILL,SIG_DFL) ret:%d, errno:%d expected ret:-1, errno:%d", - TEST_RETURN, TEST_ERRNO, EINVAL); - tst_resm(TFAIL, mesg); - } - -} /* End of sigdfl_test. */ - -/*************************************************************** - * 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(); - - /* 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() */ - -/*********************************************************************** - * Signal handler routine that used by the parent to handler - * a time out situation. It will attempt to kill the child and - * call cleanup. - ***********************************************************************/ -void -p_timeout_handler() -{ - kill(Pid, SIGKILL); - cleanup(); -} - -/*********************************************************************** - * Signal handler routine that used by the child to handle - * a time out situation. It will set a global varaible and return - * if called. - ***********************************************************************/ -void -c_timeout_handler() -{ - exit_val = TIMED_OUT; - return; -} - -/*********************************************************************** - * This signal handling routine will set a global variable and return - * if called. - ***********************************************************************/ -void -catchsig() -{ - exit_val = SIG_CAUGHT; - return; -} - -/*********************************************************************** - * Update timing information - ***********************************************************************/ -void -update_timings(atblock) -struct tblock atblock; -{ - tblock.tb_max += atblock.tb_max; - tblock.tb_min += atblock.tb_min; - tblock.tb_total += atblock.tb_total; - tblock.tb_count += atblock.tb_count; -} diff --git a/winsup/testsuite/winsup.api/ltp/stat01.c b/winsup/testsuite/winsup.api/ltp/stat01.c deleted file mode 100644 index da3596e17..000000000 --- a/winsup/testsuite/winsup.api/ltp/stat01.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: stat01 - * - * Test Description: - * Verify that, stat(2) succeeds to get the status of a file and fills the - * stat structure elements. - * - * Expected Result: - * stat() should return value 0 on success and fills the stat structure - * elements with the specified 'file' information. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * stat01 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * - */ -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define FILE_MODE 0644 -#define TESTFILE "testfile" -#define FILE_SIZE 1024 -#define BUF_SIZE 256 -#define MASK 0777 - -const char *TCID="stat01"; /* 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}; -uid_t User_id; /* Owner id of the test file */ -gid_t Group_id; /* Group id of the test file */ -char nobody_uid[] = "nobody"; -struct passwd *ltpuser; - -void setup(); /* Setup function for the test */ -void cleanup(void) __attribute__((noreturn)); /* Cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat structure buffer */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - /*NOTREACHED*/ - } - - /* Perform global setup for test */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count = 0; - - /* - * Call stat(2) to get the status of - * specified 'file' into stat structure. - */ - TEST(stat(TESTFILE, &stat_buf)); - - /* check return code of stat(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, \ - "stat(%s, &stat_buf) Failed, errno=%d : %s", - TESTFILE, TEST_ERRNO, strerror(TEST_ERRNO)); - } else { - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - stat_buf.st_mode &= ~S_IFREG; - /* - * Verify the data returned by stat(2) - * aganist the expected data. - */ - if ((stat_buf.st_uid != User_id) || \ - (stat_buf.st_gid != Group_id) || \ - (stat_buf.st_size != FILE_SIZE) || \ - ((stat_buf.st_mode & MASK) != FILE_MODE)) { - tst_resm(TFAIL, "Functionality of " - "stat(2) on '%s' Failed", - TESTFILE); - } else { - tst_resm(TPASS, "Functionality of " - "stat(2) on '%s' Succcessful", - TESTFILE); - } - } else { - tst_resm(TINFO, "Call succeeded"); - } - } - Tst_count++; /* incr. TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - /*NOTREACHED*/ - -} /* End main */ - -/* - * void - * setup() - Performs setup function for the test. - * Creat a temporary directory and change directory to it. - * Creat a testfile and write some known data into it. - * Get the effective uid/gid of test process. - */ -void -setup() -{ - int i, fd; - char tst_buff[BUF_SIZE]; - int wbytes; - int write_len = 0; - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); -#if 0 - /* Switch to nobody user for correct error code collection */ - if (geteuid() != 0) { - tst_brkm(TBROK, tst_exit, "Test must be run as root"); - } - ltpuser = getpwnam(nobody_uid); - if (setuid(ltpuser->pw_uid) == -1) { - tst_resm(TINFO, "setuid failed to " - "to set the effective uid to %d", - ltpuser->pw_uid); - perror("setuid"); - } -#endif - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - if ((fd = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - /*NOTREACHED*/ - } - - /* Fill the test buffer with the known data */ - for (i = 0; i < BUF_SIZE; i++) { - tst_buff[i] = 'a'; - } - - /* Write to the file 1k data from the buffer */ - while (write_len < FILE_SIZE) { - if ((wbytes = write(fd, tst_buff, sizeof(tst_buff))) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - /*NOTREACHED*/ - } else { - write_len += wbytes; - } - } - - /* Close the testfile created */ - if (close(fd) == -1) { - tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } - - /* Get the uid/gid of the process */ - User_id = getuid(); - Group_id = getgid(); - -} /* End setup() */ - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test file and temporary directory created. - */ -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/stat02.c b/winsup/testsuite/winsup.api/ltp/stat02.c deleted file mode 100644 index 745476fa0..000000000 --- a/winsup/testsuite/winsup.api/ltp/stat02.c +++ /dev/null @@ -1,276 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: stat02 - * - * Test Description: - * Verify that, stat(2) succeeds to get the status of a file and fills the - * stat structure elements though process doesn't have read access to the - * file. - * - * Expected Result: - * stat() should return value 0 on success and the stat structure elements - * should be filled with specified 'file' information. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * stat02 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * - */ -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define TESTFILE "testfile" -#define FILE_SIZE 1024 -#define BUF_SIZE 256 -#define NEW_MODE 0222 -#define MASK 0777 - -const char *TCID="stat02"; /* 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}; -uid_t User_id; /* eff. user id/group id of test process */ -gid_t Group_id; -char nobody_uid[] = "nobody"; -struct passwd *ltpuser; - -void setup(); /* Setup function for the test */ -void cleanup(void) __attribute__((noreturn)); /* Cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat structure buffer */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (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 -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count = 0; - - /* - * Call stat(2) to get the status of - * specified 'file' into stat structure. - */ - TEST(stat(TESTFILE, &stat_buf)); - - /* check return code of stat(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, - "stat(%s, &stat_buf) Failed, errno=%d : %s", - TESTFILE, TEST_ERRNO, strerror(TEST_ERRNO)); - } else { - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - stat_buf.st_mode &= ~S_IFREG; - /* - * Verify the data returned by stat(2) - * aganist the expected data. - */ - if ((stat_buf.st_uid != User_id) || \ - (stat_buf.st_gid != Group_id) || \ - (stat_buf.st_size != FILE_SIZE) || \ - ((stat_buf.st_mode & MASK) != NEW_MODE)) { - tst_resm(TFAIL, "Functionality of " - "stat(2) on '%s' Failed", - TESTFILE); - } else { - tst_resm(TPASS, "Functionality of " - "stat(2) on '%s' Succcessful", - TESTFILE); - } - } else { - tst_resm(TPASS, "Call succeeded"); - } - } - Tst_count++; /* incr TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - /*NOTREACHED*/ - -} /* End main */ - -/* - * void - * setup() - Performs setup function for the test. - * Creat a temporary directory and change directory to it. - * Creat a testfile and write some data into it. - * Modify the mode permissions of testfile such that test process - * has read-only access to testfile. - */ -void -setup() -{ - int i, fd; /* counter, file handle for file */ - char tst_buff[BUF_SIZE]; /* data buffer for file */ - int wbytes; /* no. of bytes written to file */ - int write_len = 0; - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); -#if 0 - /* Switch to nobody user for correct error code collection */ - if (geteuid() != 0) { - tst_brkm(TBROK, tst_exit, "Test must be run as root"); - } - ltpuser = getpwnam(nobody_uid); - if (setuid(ltpuser->pw_uid) == -1) { - tst_resm(TINFO, "setuid failed to " - "to set the effective uid to %d", - ltpuser->pw_uid); - perror("setuid"); - } -#endif - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - if ((fd = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - /*NOTREACHED*/ - } - - /* Fill the test buffer with the known data */ - for (i = 0; i < BUF_SIZE; i++) { - tst_buff[i] = 'a'; - } - - /* Write to the file 1k data from the buffer */ - while (write_len < FILE_SIZE) { - if ((wbytes = write(fd, tst_buff, sizeof(tst_buff))) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - /*NOTREACHED*/ - } else { - write_len += wbytes; - } - } - - if (close(fd) == -1) { - tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } - - /* Modify mode permissions on the testfile */ - if (chmod(TESTFILE, NEW_MODE) < 0) { - tst_brkm(TBROK, cleanup, - "chmod(2) on %s Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - /*NOTREACHED*/ - } - - /* Get the uid/gid of the process */ - User_id = getuid(); - Group_id = getgid(); - -} /* End setup() */ - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory and file created. - */ -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/stat03.c b/winsup/testsuite/winsup.api/ltp/stat03.c deleted file mode 100644 index dcddfd2a0..000000000 --- a/winsup/testsuite/winsup.api/ltp/stat03.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: stat03 - * - * Test Description: - * Verify that, - * 1) stat(2) returns -1 and sets errno to EACCES if search permission is - * denied on a component of the path prefix. - * 2) stat(2) returns -1 and sets errno to ENOENT if the specified file - * does not exists or empty string. - * 3) stat(2) returns -1 and sets errno to EFAULT if pathname points - * outside user's accessible address space. - * 4) stat(2) returns -1 and sets errno to ENAMETOOLONG if the pathname - * component is too long. - * 5) stat(2) returns -1 and sets errno to ENOTDIR if the directory - * component in pathname is not a directory. - * - * Expected Result: - * stat() should fail with return value -1 and set expected errno. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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) - * if errno set == expected errno - * Issue sys call fails with expected return value and errno. - * Otherwise, - * Issue sys call fails with unexpected errno. - * Otherwise, - * Issue sys call returns unexpected value. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory(s)/file(s) created. - * - * Usage: - * stat03 [-c n] [-e] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define MODE_RWX S_IRWXU | S_IRWXG | S_IRWXO -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define DIR_TEMP "testdir_1" -#define TEST_FILE1 "testdir_1/tfile_1" -#define TEST_FILE2 "t_file/tfile_2" - -int no_setup(); -int setup1(); /* setup function to test chmod for EACCES */ -int setup2(); /* setup function to test chmod for ENOTDIR */ -int longpath_setup(); /* setup function to test chmod for ENAMETOOLONG */ -char nobody_uid[] = "nobody"; -struct passwd *ltpuser; - - -char Longpathname[PATH_MAX+2]; -char High_address_node[64]; - -struct test_case_t { /* test case struct. to hold ref. test cond's*/ - const char *pathname; - const char *desc; - int exp_errno; - int (*setupfunc)(); -} Test_cases[] = { -#ifndef __CYGWIN__ - { TEST_FILE1, "No Search permissions to process", EACCES, setup1 }, -#endif - { High_address_node, "Address beyond address space", EFAULT, no_setup }, - { (char *)-1, "Negative address", EFAULT, no_setup }, - { Longpathname, "Pathname too long", ENAMETOOLONG, longpath_setup }, - { "", "Pathname is empty", ENOENT, no_setup }, -#ifndef __CYGWIN__ - { TEST_FILE2, "Path contains regular file", ENOTDIR, setup2 }, -#endif - { NULL, NULL, 0, no_setup } -}; - -const char *TCID="stat03"; /* 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[]={EACCES, EFAULT, ENAMETOOLONG, ENOENT, ENOTDIR, 0}; - -void setup(); /* Main setup function for the tests */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ -char *get_high_address(void); - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat structure buffer */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - const char *file_name; /* ptr. for file name whose mode is modified*/ - const char *test_desc; /* test specific error message */ - int ind; /* counter to test different test conditions */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - /*NOTREACHED*/ - } - - /* - * Invoke setup function to call individual test setup functions - * to simulate test conditions. - */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Check looping state if -i 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++) { - file_name = Test_cases[ind].pathname; - test_desc = Test_cases[ind].desc; - - if (file_name == High_address_node) { - file_name = (char *)get_high_address(); - } - - /* - * Call stat(2) to test different test conditions. - * verify that it fails with -1 return value and - * sets appropriate errno. - */ - TEST(stat(file_name, &stat_buf)); - - /* Check return code from stat(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO == Test_cases[ind].exp_errno) { - tst_resm(TPASS, - "stat() fails, %s, errno:%d", - test_desc, TEST_ERRNO); - } else { - tst_resm(TFAIL, "stat() fails, %s," - " errno:%d, expected errno:%d", - test_desc, TEST_ERRNO, - Test_cases[ind].exp_errno); - } - } else { - tst_resm(TFAIL, "stat(2) returned %d," - " expected -1, errno:%d", TEST_RETURN, - Test_cases[ind].exp_errno); - } - } /* End of TEST CASE LOOPING. */ - Tst_count++; /* incr TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* - * Invoke cleanup() to delete the test directory/file(s) created - * in the setup(). - */ - cleanup(); - /*NOTREACHED*/ - -} /* End main */ - -/* - * void - * setup(void) - performs all ONE TIME setup for this test. - * Exit the test program on receipt of unexpected signals. - * Create a temporary directory and change directory to it. - * Invoke individual test setup functions according to the order - * set in struct. definition. - */ -void -setup() -{ - int ind; /* counter for setup functions */ - - /* Capture unexpected signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); -#if 0 - /* Switch to nobody user for correct error code collection */ - if (geteuid() != 0) { - tst_brkm(TBROK, tst_exit, "Test must be run as root"); - } - ltpuser = getpwnam(nobody_uid); - if (setuid(ltpuser->pw_uid) == -1) { - tst_resm(TINFO, "setuid failed to " - "to set the effective uid to %d", - ltpuser->pw_uid); - perror("setuid"); - } -#endif - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* Make a temp dir and cd to it */ - tst_tmpdir(); - - /* call individual setup functions */ - for (ind = 0; Test_cases[ind].desc != NULL; ind++) { - Test_cases[ind].setupfunc(); - } -} /* End setup() */ - -/* - * int - * no_setup() - Some test conditions for stat(2) do not any setup. - * Hence, this function just returns 0. - * This function simply returns 0. - */ -int -no_setup() -{ - return 0; -} - - -/* - * int - * setup1() - setup function for a test condition for which stat(2) - * returns -1 and sets errno to EACCES. - * Create a test directory under temporary directory and create a test file - * under this directory with mode "0666" permissions. - * Modify the mode permissions on test directory such that process will not - * have search permissions on test directory. - * - * The function returns 0. - */ -int -setup1() -{ - int fd; /* file handle for testfile */ - - /* Creat a test directory */ - if (mkdir(DIR_TEMP, MODE_RWX) < 0) { - tst_brkm(TBROK, cleanup, "mkdir(2) of %s failed", DIR_TEMP); - /*NOTREACHED*/ - } - - /* Creat a test file under above test directory */ - if ((fd = open(TEST_FILE1, O_RDWR|O_CREAT, 0666)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, 0666) failed, errno=%d : %s", - TEST_FILE1, errno, strerror(errno)); - /*NOTREACHED*/ - } - /* Close the test file */ - if (close(fd) == -1) { - tst_brkm(TBROK, cleanup, - "close(%s) Failed, errno=%d : %s", - TEST_FILE1, errno, strerror(errno)); - /*NOTREACHED*/ - } - - /* Modify mode permissions on test directory */ - if (chmod(DIR_TEMP, FILE_MODE) < 0) { - tst_brkm(TBROK, cleanup, "chmod(2) of %s failed", DIR_TEMP); - /*NOTREACHED*/ - } - return 0; -} - -/* - * int - * setup2() - setup function for a test condition for which stat(2) - * returns -1 and sets errno to ENOTDIR. - * - * Create a test file under temporary directory so that test tries to - * change mode of a testfile "tfile_2" under "t_file" which happens to be - * another regular file. - */ -int -setup2() -{ - int fd; /* File handle for test file */ - - /* Creat a test file under temporary directory */ - if ((fd = open("t_file", O_RDWR|O_CREAT, MODE_RWX)) == -1) { - tst_brkm(TBROK, cleanup, - "open(2) on t_file failed, errno=%d : %s", - errno, strerror(errno)); - /*NOTREACHED*/ - } - /* Close the test file created above */ - if (close(fd) == -1) { - tst_brkm(TBROK, cleanup, - "close(t_file) Failed, errno=%d : %s", - errno, strerror(errno)); - /*NOTREACHED*/ - } - return 0; -} - -/* - * int - * longpath_setup() - setup to create a node with a name length exceeding - * the MAX. length of PATH_MAX. - * This function retruns 0. - */ -int -longpath_setup() -{ - int ind; /* counter variable */ - - for (ind = 0; ind <= (PATH_MAX + 1); ind++) { - Longpathname[ind] = 'a'; - } - return 0; -} - -/* - * void - * cleanup() - Performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Print test timing stats and errno log if test executed with options. - * Remove temporary directory and sub-directories/files under it - * created during setup(). - * Exit the test program with normal exit code. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - -#ifndef __CYGWIN__ - /* Restore mode permissions on test directory created in setup2() */ - if (chmod(DIR_TEMP, MODE_RWX) < 0) { - tst_brkm(TFAIL, NULL, "chmod(2) of %s failed", DIR_TEMP); - } -#endif - - /* Remove files and temporary directory created */ - 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 deleted file mode 100644 index 5c0964a93..000000000 --- a/winsup/testsuite/winsup.api/ltp/stat05.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/stat06.c b/winsup/testsuite/winsup.api/ltp/stat06.c deleted file mode 100644 index c5fae6fe5..000000000 --- a/winsup/testsuite/winsup.api/ltp/stat06.c +++ /dev/null @@ -1,377 +0,0 @@ -/* - * 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 : stat06 - * - * EXECUTED BY : anyone - * - * TEST TITLE : stat(2) negative path testcases - * - * PARENT DOCUMENT : None - * - * TEST CASE TOTAL : 7 - * - * 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-7) See Testcases structure below. - * - * INPUT SPECIFICATIONS - * The standard options for system call tests are accepted. - * (See the parse_opts(3) man page). - * -h : print help and exit - * - * 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 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 -#include -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - -const char *TCID="stat06"; /* Test program identifier. */ -int TST_TOTAL=8; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -extern char *get_high_address(); - -int exp_enos[]={0, 0}; - -int high_address_setup(); -int longpath_setup(); -int no_setup(); -int filepath_setup(); -char Longpathname[PATH_MAX+2]; -char High_address[64]; -struct stat statbuf; -jmp_buf sig11_recover; -void sig11_handler(int sig); - -struct test_case_t { - const char *pathname; - struct stat *stbuf; - const char *desc; - int exp_errno; - int (*setupfunc)(); -} Test_cases[] = { - { "nonexistfile", &statbuf, "non-existent file", ENOENT, no_setup}, - { "", &statbuf, "path is empty string", ENOENT, no_setup}, - { "nefile/file", &statbuf, "path contains a non-existent file", - ENOENT, no_setup }, -#ifndef __CYGWIN__ - { "file/file", &statbuf, "path contains a regular file", - ENOTDIR, filepath_setup }, -#endif - { Longpathname, &statbuf, "pathname too long", ENAMETOOLONG, longpath_setup }, - { High_address, &statbuf, "address beyond address space", EFAULT, high_address_setup }, - { (char *)-1, &statbuf, "negative address", EFAULT, no_setup }, - { "file", (struct stat *)-1, "invalid struct stat address", EFAULT, filepath_setup }, - { NULL, NULL, NULL, 0, no_setup } -}; - -/*********************************************************************** - * Main - ***********************************************************************/ -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - const char *fname; - const char *desc; - int ind; - struct stat *stbuf; - struct sigaction sa, osa; - - /*************************************************************** - * 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; - stbuf = Test_cases[ind].stbuf; - - if (stbuf == (struct stat *)-1) { - /* special sig11 case */ - sa.sa_handler = &sig11_handler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - - sigaction(SIGSEGV, NULL, &osa); - sigaction(SIGSEGV, &sa, NULL); - - if (setjmp(sig11_recover)) { - TEST_RETURN = -1; - TEST_ERRNO = EFAULT; - } else { - TEST(stat(fname, stbuf)); - } - sigaction(SIGSEGV, &osa, NULL); - } else { - /* - * Call stat(2) - */ - - TEST(stat(fname, stbuf)); - } - - /* check return code */ - if ( TEST_RETURN == -1 ) { - if ( STD_FUNCTIONAL_TEST ) { - if ( TEST_ERRNO == Test_cases[ind].exp_errno ) - tst_resm(TPASS, "stat(<%s>, &stbuf) Failed, errno=%d", - desc, TEST_ERRNO); - else - tst_resm(TFAIL, - "stat(<%s>, &stbuf) Failed, errno=%d, expected errno:%d", - desc, TEST_ERRNO, Test_cases[ind].exp_errno); - } - else - Tst_count++; - } else { - tst_resm(TFAIL, - "stat(<%s>, &stbuf) 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() -{ - /* - * 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() */ - -/****************************************************************** - * no_setup() - does nothing - ******************************************************************/ -int -no_setup() -{ - return 0; -} - -/****************************************************************** - * high_address_setup() - generates an address that should cause a segfault - ******************************************************************/ -int -high_address_setup() -{ - int ind; - - for (ind=0; Test_cases[ind].desc != NULL; ind++ ) { - if ( Test_cases[ind].pathname == High_address ) { - /*if ( strcmp(Test_cases[ind].pathname, HIGH_ADDRESS) == 0 ) { ***/ - Test_cases[ind].pathname = get_high_address(); - break; - } - } - return 0; - -} - -/****************************************************************** - * longpath_setup() - creates a filename that is too long - ******************************************************************/ -int -longpath_setup() -{ - int ind; - - for(ind=0; ind<= PATH_MAX+1; ind++) { - Longpathname[ind] = 'a'; - } - return 0; - -} - -/****************************************************************** - * filepath_setup() creates a file the exists that we will treat as a directory - ******************************************************************/ -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; -} - -/****************************************************************** - * sig11_handler() - our segfault recover hack - ******************************************************************/ -void -sig11_handler(int sig) -{ - longjmp(sig11_recover, 1); -} diff --git a/winsup/testsuite/winsup.api/ltp/symlink01.c b/winsup/testsuite/winsup.api/ltp/symlink01.c deleted file mode 100644 index 660a6d2e6..000000000 --- a/winsup/testsuite/winsup.api/ltp/symlink01.c +++ /dev/null @@ -1,2032 +0,0 @@ -/* - * 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 -#include -#include /* open(2) system call */ -#include -#include -#include /* utime(2) system call */ -#include -#include /* stat(2) and lstat(2) system calls */ - -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); -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 ALL 1 - -#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 - */ -const 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 -{ - const char *tcid; - int test_fail; - int errno_val; - int pass_msg; - int (*test_setup)(); - int (*ck_test)(); - const 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 -{ - const char *tcid; - const char *syscall; - int test_cases; /* number of entries in test_objects array */ - struct all_test_cases *tc_ptr; - const 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; -const char *TCID = NULL; -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 */ - const 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; - - } - else { - TCID = DEFAULT_TCID; -#ifndef ALL - Selectedtests = DEFAULT_TCID; -#else - Selectedtests = NULL; -#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; -{ - unsigned 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 buf [PATH_MAX]; - char *cwd; - - if ((cwd = getcwd(buf, sizeof (buf))) == 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); - } - 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++) { - - if (tc_ptr->test_fail < 0) continue; - - Buffer[0]='\0'; - - /* - * If running all test cases for all tcid, set the TCID if needed. - */ - if ( Selectedtests == NULL ) { - if ( !TCID || strcmp(TCID, tc_ptr->tcid) != 0 ) { - TCID = tc_ptr->tcid; - Tst_count=0; - } - } - /* - * Insure that we are executing the correct tcs test case - */ - if (strcmp(TCID, tc_ptr->tcid) != 0) { - tst_resm(TBROK, "%s TCID attempted to execute %s %d %d test case", - 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)); - close (TEST_RETURN); - } - 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)); - close (TEST_RETURN); - } - 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)); - close (fd); - } - 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 buf [PATH_MAX]; - char *cwd; - 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(buf, sizeof (buf))) == 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() -{ - unsigned ind; - - printf(" -T id Determines which tests cases to execute:\n"); - - for (ind=0; ind -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/symlink03.c b/winsup/testsuite/winsup.api/ltp/symlink03.c deleted file mode 100644 index 4d0542768..000000000 --- a/winsup/testsuite/winsup.api/ltp/symlink03.c +++ /dev/null @@ -1,404 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name : symlink03 - * - * Test Description : - * Verify that, - * 1) symlink(2) returns -1 and sets errno to EACCES if search/write - * permission is denied in the directory where the symbolic link is - * being created. - * 2) symlink(2) returns -1 and sets errno to EEXIST if the specified - * symbolic link already exists. - * 3) symlink(2) returns -1 and sets errno to EFAULT if the specified - * file or symbolic link points to invalid address. - * 4) symlink(2) returns -1 and sets errno to ENAMETOOLONG if the - * pathname component of symbolic link is too long (ie, > PATH_MAX). - * 5) symlink(2) returns -1 and sets errno to ENOTDIR if the directory - * component in pathname of symbolic link is not a directory. - * 6) symlink(2) returns -1 and sets errno to ENOENT if the component of - * symbolic link points to an empty string. - * - * Expected Result: - * symlink() should fail with return value -1 and set expected errno. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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) - * if errno set == expected errno - * Issue sys call fails with expected return value and errno. - * Otherwise, - * Issue sys call fails with unexpected errno. - * Otherwise, - * Issue sys call returns unexpected value. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory(s)/file(s) created. - * - * Usage: - * symlink03 [-c n] [-e] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * This test should be executed by 'non-super-user' only. - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define MODE_RWX S_IRWXU | S_IRWXG | S_IRWXO -#define FILE_MODE S_IRUSR | S_IRGRP | S_IROTH -#define DIR_TEMP "testdir_1" -#define TESTFILE "testfile" -#define TEST_FILE1 "testdir_1/tfile_1" -#define SYM_FILE1 "testdir_1/sfile_1" -#define TEST_FILE2 "tfile_2" -#define SYM_FILE2 "sfile_2" -#define TEST_FILE3 "tfile_3" -#define SYM_FILE3 "t_file/sfile_3" - -const char *TCID="symlink03"; /* 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[]={ENOTDIR, ENOENT, ENAMETOOLONG, EFAULT, EEXIST, EACCES, 0}; - -int no_setup(); -int setup1(); /* setup function to test symlink for EACCES */ -int setup2(); /* setup function to test symlink for EEXIST */ -int setup3(); /* setup function to test symlink for ENOTDIR */ -int longpath_setup(); /* setup function to test chmod for ENAMETOOLONG */ - -char Longpathname[PATH_MAX+2]; -char High_address_node[64]; - -struct test_case_t { /* test case struct. to hold ref. test cond's*/ - const char *file; - const char *link; - const char *desc; - int exp_errno; - int (*setupfunc)(); -} Test_cases[] = { - { TEST_FILE1, SYM_FILE1, "No Search permissions to process", EACCES, setup1 }, - { TEST_FILE2, SYM_FILE2, "Specified symlink already exists", EEXIST, setup2 }, - { TESTFILE, High_address_node, "Address beyond address space", EFAULT, no_setup }, - { TESTFILE, (char *)-1, "Negative address", EFAULT, no_setup }, - { TESTFILE, Longpathname, "Symlink path too long", ENAMETOOLONG, longpath_setup }, - { TESTFILE, "", "Symlink Pathname is empty", ENOENT, no_setup }, -#ifndef __CYGWIN__ - { TEST_FILE3, SYM_FILE3, "Symlink Path contains regular file", ENOTDIR, setup3 }, -#endif - { NULL, NULL, NULL, 0, no_setup } -}; - -extern void setup(); /* Setup function for the test */ -void cleanup() __attribute__((noreturn));/* Cleanup function for the test */ -char *get_high_address (void); - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - const char *test_file; /* testfile name */ - const char *sym_file; /* symbolic link file name */ - const char *test_desc; /* test specific error message */ - int ind; /* counter to test different test conditions */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - /*NOTREACHED*/ - } - - /* - * Invoke setup function to call individual test setup functions - * to simulate test conditions. - */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Check looping state if -i 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++) { - test_file = Test_cases[ind].file; - sym_file = Test_cases[ind].link; - test_desc = Test_cases[ind].desc; - - if (sym_file == High_address_node) { - sym_file = (char *)get_high_address(); - } - /* - * Call symlink(2) to test different test conditions. - * verify that it fails with -1 return value and sets - * appropriate errno. - */ - TEST(symlink(test_file, sym_file)); - - /* Check return code of symlink(2) */ - if (TEST_RETURN == -1) { - /* - * Perform functional verification if - * test executed without (-f) option. - */ - TEST_ERROR_LOG(TEST_ERRNO); - if (TEST_ERRNO == Test_cases[ind].exp_errno) { - tst_resm(TPASS, "symlink() Fails, %s, " - "errno=%d", test_desc, - TEST_ERRNO); - } else { - tst_resm(TFAIL, "symlink() Fails, %s, " - "errno=%d, expected errno=%d", - test_desc, TEST_ERRNO, - Test_cases[ind].exp_errno); - } - } else { - tst_resm(TFAIL, "symlink() returned %d, " - "expected -1, errno:%d", TEST_RETURN, - Test_cases[ind].exp_errno); - } - } /* End of TEST CASE LOOPING. */ - - Tst_count++; /* incr. TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - /*NOTREACHED*/ - -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Call test specific setup functions. - */ -void -setup() -{ - int ind; - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* call individual setup functions */ - for (ind = 0; Test_cases[ind].desc != NULL; ind++) { - Test_cases[ind].setupfunc(); - } -} /* End setup() */ - -/* - * int - * no_setup() - Some test conditions for mknod(2) do not any setup. - * Hence, this function just returns 0. - * This function simply returns 0. - */ -int -no_setup() -{ - return 0; -} - -/* - * int - * setup1() - setup function for a test condition for which symlink(2) - * returns -1 and sets errno to EACCES. - * Create a test directory under temporary directory and create a test file - * under this directory with mode "0666" permissions. - * Modify the mode permissions on test directory such that process will not - * have search permissions on test directory. - * - * The function returns 0. - */ -int -setup1() -{ - int fd; /* file handle for testfile */ - - if (mkdir(DIR_TEMP, MODE_RWX) < 0) { - tst_brkm(TBROK, cleanup, "mkdir(2) of %s failed", DIR_TEMP); - /*NOTREACHED*/ - } - - if ((fd = open(TEST_FILE1, O_RDWR|O_CREAT, 0666)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, 0666) failed, errno=%d : %s", - TEST_FILE1, errno, strerror(errno)); - /*NOTREACHED*/ - } - if (close(fd) == -1) { - tst_brkm(TBROK, cleanup, - "close(%s) Failed, errno=%d : %s", - TEST_FILE1, errno, strerror(errno)); - /*NOTREACHED*/ - } - - /* Modify mode permissions on test directory */ - if (chmod(DIR_TEMP, FILE_MODE) < 0) { - tst_brkm(TBROK, cleanup, "chmod(2) of %s failed", DIR_TEMP); - /*NOTREACHED*/ - } - return 0; -} - -/* - * int - * setup2() - EEXIST - */ -int -setup2() -{ - int fd; /* file handle for testfile */ - - if ((fd = open(TEST_FILE2, O_RDWR|O_CREAT, 0666)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, 0666) failed, errno=%d : %s", - TEST_FILE1, errno, strerror(errno)); - /*NOTREACHED*/ - } - if (close(fd) == -1) { - tst_brkm(TBROK, cleanup, - "close(%s) Failed, errno=%d : %s", - TEST_FILE2, errno, strerror(errno)); - /*NOTREACHED*/ - } - - if (symlink(TEST_FILE2, SYM_FILE2) < 0) { - tst_brkm(TBROK, cleanup, - "symlink() Fails to create %s in setup2, error=%d", - SYM_FILE2, errno); - /*NOTREACHED*/ - } - return 0; -} - -/* - * int - * longpath_setup() - setup to create a node with a name length exceeding - * the MAX. length of PATH_MAX. - * This function retruns 0. - */ -int -longpath_setup() -{ - int ind; /* counter variable */ - - for (ind = 0; ind <= (PATH_MAX + 1); ind++) { - Longpathname[ind] = 'a'; - } - return 0; -} - -/* - * int - * setup3() - setup function for a test condition for which symlink(2) - * returns -1 and sets errno to ENOTDIR. - * - * Create a symlink file under temporary directory so that test tries to - * create symlink file "tfile_3" under "t_file" which happens to be - * another symlink file. - */ -int -setup3() -{ - int fd; /* file handle for testfile */ - - /* Creat/open a testfile and close it */ - if ((fd = open("t_file", O_RDWR|O_CREAT, MODE_RWX)) == -1) { - tst_brkm(TBROK, cleanup, - "open(2) on t_file failed, errno=%d : %s", - errno, strerror(errno)); - /*NOTREACHED*/ - } - if (close(fd) == -1) { - tst_brkm(TBROK, cleanup, "close(t_file) Failed, errno=%d : %s", - errno, strerror(errno)); - /*NOTREACHED*/ - } - return 0; -} - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Restore the mode permissions on test directory. - * Remove the temporary directory created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Restore mode permissions on test directory created in setup2() */ - if (chmod(DIR_TEMP, MODE_RWX) < 0) { - tst_brkm(TBROK, NULL, "chmod(2) of %s failed", DIR_TEMP); - } - - /* 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/symlink04.c b/winsup/testsuite/winsup.api/ltp/symlink04.c deleted file mode 100644 index c6ddd0630..000000000 --- a/winsup/testsuite/winsup.api/ltp/symlink04.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name : symlink01 - * - * Test Description : - * Verify that, symlink will succeed to creat a symbolic link of an existing - * object name path. - * - * Expected Result: - * symlink() should return value 0 on success and symbolic link of an - * existing object should be created. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * symlink01 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * None. - * - */ - -#include -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -#define TESTFILE "testfile" -#define SYMFILE "slink_file" -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH - -const char *TCID="symlink01"; /* 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}; - -extern void setup(); /* Setup function for the test */ -void cleanup() __attribute__((noreturn));/* Cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat structure buffer */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - /*NOTREACHED*/ - } - - /* Perform global setup for test */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call symlink(2) to create a symlink of - * testfile. - */ - TEST(symlink(TESTFILE, SYMFILE)); - - /* Check return code of symlink(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, "symlink(%s, %s) Failed, errno=%d : %s", - TESTFILE, SYMFILE, TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Get the symlink file status information - * using lstat(2). - */ - if (lstat(SYMFILE, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, "lstat(2) of " - "%s failed, error:%d", SYMFILE, - errno); - /*NOTREACHED*/ - } - - /* Check if the st_mode contains a link */ - if (!S_ISLNK(stat_buf.st_mode)) { - tst_resm(TFAIL, - "symlink of %s doesn't exist", - TESTFILE); - } else { - tst_resm(TPASS, "symlink(%s, %s) " - "functionality successful", - TESTFILE, SYMFILE); - } - } else { - tst_resm(TPASS, "Call succeeded"); - } - } - - /* Unlink the symlink file for next loop */ - if (unlink(SYMFILE) == -1) { - tst_brkm(TBROK, cleanup, - "unlink(%s) Failed, errno=%d : %s", - SYMFILE, errno, strerror(errno)); - /*NOTREACHED*/ - } - Tst_count++; /* incr TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - /*NOTREACHED*/ - -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and close it - */ -void -setup() -{ - int fd; /* file handle for testfile */ - - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* creat/open a testfile */ - if ((fd = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - /*NOTREACHED*/ - } - - /* Close the temporary file created above */ - if (close(fd) == -1) { - tst_resm(TBROK, "close(%s) Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } -} /* End setup() */ - - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test directory and testfile created in the setup. - */ -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/symlink05.c b/winsup/testsuite/winsup.api/ltp/symlink05.c deleted file mode 100644 index 3b2bbcb8c..000000000 --- a/winsup/testsuite/winsup.api/ltp/symlink05.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name : symlink02 - * - * Test Description : - * Verify that, symlink will succeed to creat a symbolic link of an - * non-existing object name path. - * - * Expected Result: - * symlink() should return value 0 on success and symlink of an - * non-existing object should be created. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * symlink02 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * This test should be run by 'non-super-user' only. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TESTFILE "testfile" -#define SYMFILE "slink_file" - -const 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}; - -extern void setup(); /* Setup function for the test */ -void cleanup() __attribute__((noreturn));/* Cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat structure buffer */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - tst_exit(); - /*NOTREACHED*/ - } - - /* Perform global setup for test */ - setup(); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call symlink(2) to create a symlink of - * an non-existing testfile. - */ - TEST(symlink(TESTFILE, SYMFILE)); - - /* Check return code of symlink(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, \ - "symlink(%s, %s) Failed, errno=%d : %s", - TESTFILE, SYMFILE, TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Get the symlink file status information - * using lstat(2). - */ - if (lstat(SYMFILE, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, "lstat(2) of " - "%s failed, error:%d", - SYMFILE, errno); - /*NOTREACHED*/ - } - - /* Check if the st_mode contains a link */ - if (!S_ISLNK(stat_buf.st_mode)) { - tst_resm(TFAIL, \ - "symlink of %s doesn't exist", - TESTFILE); - } else { - tst_resm(TPASS, "symlink(%s, %s) " - "functionality successful", - TESTFILE, SYMFILE); - } - } else { - tst_resm(TPASS, "Call succeeded"); - } - } - - /* Unlink the symlink file for next loop */ - if (unlink(SYMFILE) == -1) { - tst_brkm(TBROK, cleanup, - "unlink(%s) Failed, errno=%d : %s", - SYMFILE, errno, strerror(errno)); - } - Tst_count++; /* incr TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - /*NOTREACHED*/ - -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - */ -void -setup() -{ - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - -} /* End setup() */ - - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory created in the setup. - */ -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 deleted file mode 100644 index c7df322ea..000000000 --- a/winsup/testsuite/winsup.api/ltp/sync01.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * 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 -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/sync02.c b/winsup/testsuite/winsup.api/ltp/sync02.c deleted file mode 100644 index 5535e1add..000000000 --- a/winsup/testsuite/winsup.api/ltp/sync02.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: sync01 - * - * Test Description: - * Open a file for write; modify the file, then do a sync(). - * Verify that the data has been written to disk by re-opening the file. - * - * Expected Result: - * sync() alawys returns 0 in Linux. The data written to the file should - * be updated to the disk. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * sync01 [-c n] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * None. - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TEMP_FILE "temp_file" -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH - -const 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 */ -char write_buffer[BUFSIZ]; /* buffer used to write data to file*/ -int fildes; /* file descriptor for temporary file */ - -void setup(); /* Main setup function of test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - char read_buffer[BUFSIZ]; /* buffer used to read data from file*/ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (char *) NULL) { - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - /* Perform global setup for test */ - setup(); - - /* Check looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call sync(2) to commit buffer data to disk. - */ - TEST_VOID(sync()); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "%s, Failed, errno=%d : %s", - TCID, TEST_ERRNO, strerror(TEST_ERRNO)); - } else { - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* Set the file ptr to b'nning of file */ - if (lseek(fildes, 0, SEEK_SET) < 0) { - tst_brkm(TFAIL, cleanup, "lseek() " - "failed on %s, error=%d", - TEMP_FILE, errno); - /*NOTREACHED*/ - } - - /* Read the contents of file */ - if (read(fildes, read_buffer, \ - sizeof(read_buffer)) > 0) { - if (memcmp(read_buffer, write_buffer, strlen(write_buffer))) { - tst_resm(TFAIL, "Data read " - "from %s doesn't match " - "with witten data", - TEMP_FILE); - } else { - tst_resm(TPASS, "Functionality " - "of sync() successful"); - } - } else { - tst_brkm(TFAIL, cleanup, - "read() Fails on %s, error=%d", - TEMP_FILE, errno); - /*NOTREACHED*/ - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } - Tst_count++; /* incr. TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - /*NOTREACHED*/ - -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and write some - * data into it. - */ -void -setup() -{ - /* capture signals */ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Copy some data into data buffer */ - strcpy(write_buffer, "abcdefghijklmnopqrstuvwxyz"); - - /* Creat a temporary file under above directory */ - if ((fildes = open(TEMP_FILE, O_RDWR | O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR | O_CREAT, %#o) Failed, errno=%d :%s", - TEMP_FILE, FILE_MODE, errno, strerror(errno)); - /*NOTREACHED*/ - } - - /* Write the buffer data into file */ - if (write(fildes, write_buffer, strlen(write_buffer)) != \ - (int)strlen(write_buffer)) { - tst_brkm(TBROK, cleanup, - "write() failed to write buffer data to %s", - TEMP_FILE); - /*NOTREACHED*/ - } - -} /* End setup() */ - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - /* Close the temporary file */ - if (close(fildes) == -1) { - tst_brkm(TFAIL, NULL, - "close(%s) Failed, errno=%d : %s", - TEMP_FILE, 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/time01.c b/winsup/testsuite/winsup.api/ltp/time01.c deleted file mode 100644 index c5658e260..000000000 --- a/winsup/testsuite/winsup.api/ltp/time01.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/time02.c b/winsup/testsuite/winsup.api/ltp/time02.c deleted file mode 100644 index 011546e8f..000000000 --- a/winsup/testsuite/winsup.api/ltp/time02.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: time01 - * - * Test Description: - * Verify that time(2) returns the value of time in seconds since - * the Epoch and stores this value in the memory pointed to by the parameter. - * - * Expected Result: - * time() should return the time (seconds) since the Epoch and this value - * should be equal to the value stored in the specified parameter. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * - * Usage: - * time01 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * None. - * - */ - -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -extern void setup(); /* setup function for the test */ -void cleanup(void) __attribute__((noreturn));/* cleanup function for the test */ - -const 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}; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - time_t tloc; /* time_t variables for time(2) */ - - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (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 -i option given */ - for (lc=0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call time() to get the time in seconds - * since Epoch. - */ - TEST(time(&tloc)); - - /* Check return code from time(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, "time(0) Failed, errno=%d : %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - } else { - /* - * Perform functional verification if test executed - * without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - if (tloc == TEST_RETURN) { - tst_resm(TPASS, "time() returned value " - "%d, stored value %d are same", - TEST_RETURN, tloc); - } else { - tst_resm(TFAIL, "time() returned value " - "%d, stored value %d are " - "different", TEST_RETURN, tloc); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - - } - Tst_count++; /* incr. TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* cleanup and exit */ - cleanup(); - /*NOTREACHED*/ - -} /* 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/times01.c b/winsup/testsuite/winsup.api/ltp/times01.c deleted file mode 100644 index a1bd1d838..000000000 --- a/winsup/testsuite/winsup.api/ltp/times01.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/times02.c b/winsup/testsuite/winsup.api/ltp/times02.c deleted file mode 100644 index 1dae36c5a..000000000 --- a/winsup/testsuite/winsup.api/ltp/times02.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * times02.c - * - * DESCRIPTION - * Testcase to test that times() sets errno correctly - * - * ALGORITHM - * block1: Pass an invalid address as the "tms" structure, and expect - * that times() would return EFAULT. - * - * USAGE: - * times02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions - * NONE - */ - -#include -#include -#include -#include - -const char *TCID = "times02"; -int TST_TOTAL = 1; -extern int Tst_count; -int exp_enos[]={EFAULT, 0}; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int argc, char **argv) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - /* parse standard options */ - if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != - (char *)NULL) { - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); - - /* check for looping state if -i option is given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - TEST(times((void *)-1)); - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - if (errno != EFAULT) { - tst_resm(TFAIL, "Expected EFAULT, got %d", - errno); - } else { - tst_resm(TPASS, "Received EFAULT as expected"); - } - - } else { - tst_resm(TFAIL, "times(2) failed to FAIL"); - } - - } - cleanup(); - /*NOTREACHED*/ -} - -/* - * setup() - * performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -c option. - */ - TEST_PAUSE; -} - -/* - * cleanup() - * performs all ONE TIME cleanup for this test at - * completion or premature exit - */ -void -cleanup(void) -{ - /* - * 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(); - /*NOTREACHED*/ -} diff --git a/winsup/testsuite/winsup.api/ltp/times03.c b/winsup/testsuite/winsup.api/ltp/times03.c deleted file mode 100644 index 453d311cc..000000000 --- a/winsup/testsuite/winsup.api/ltp/times03.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * times01.c - * - * DESCRIPTION - * Testcase to check the basic functionality of the times() system call. - * - * ALGORITHM - * This testcase checks the values that times(2) system call returns. - * Start a process, and spend some CPU time by performing a spin in - * a for-loop. Then use the times() system call, to determine the - * cpu time/sleep time, and other statistics. - * - * USAGE: - * times01 [-c n] [-f] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions - * NONE - */ - -#include -#include -#include -#include -#include -#include - -const char *TCID = "times01"; -int TST_TOTAL = 1; -extern int Tst_count; -int exp_enos[]={0}; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int argc, char **argv) -{ - const char *msg; /* message returned from parse_opts */ - - struct tms buf1, buf2; - time_t start_time, end_time; - int i, pid2, status, fail=0; - - /* parse standard options */ - if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != - (char *)NULL) { - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); - - - for (i = 0; i < 1000000; i++); - /* - * At least some CPU time must be used. This is - * achieved by executing the times(2) call for - * atleast 5 secs. This logic makes it independant - * of the processor speed. - */ - start_time = time(NULL); - for (;;) { - if (times(&buf1) == (clock_t)-1) { - TEST_ERROR_LOG(errno); - tst_resm(TFAIL, "Call to times(2) " - "failed, errno = %d", errno); - } - end_time = time(NULL); - if ((end_time - start_time) > 5) { - break; - } - } - if (times(&buf1) == (clock_t)-1) { - TEST_ERROR_LOG(errno); - tst_resm(TFAIL, "Call to times(2) failed, " - "errno = %d", errno); - } else { - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - if (buf1.tms_utime == 0) { - tst_resm(TFAIL, "Error: times() report " - "0 user time"); - fail=1; - } - if (buf1.tms_stime == 0) { - tst_resm(TFAIL, "Error: times() report " - "0 system time"); - fail=1; - } - if (buf1.tms_cutime != 0) { - tst_resm(TFAIL, "Error: times() report " - "%d child user time", - buf1.tms_cutime); - fail=1; - } - if (buf1.tms_cstime != 0) { - tst_resm(TFAIL, "Error: times() report " "%d child system time", - buf1.tms_cstime); - fail=1; - } - - pid2 = fork(); - if (pid2 < 0) { - tst_brkm(TFAIL, cleanup, "Fork failed"); - /*NOTREACHED*/ - } else if (pid2 == 0) { - for (i = 0; i < 2000000; i++); - /* - * Atleast some CPU time must be used - * even in the child process (thereby - * making it independent of the - * processor speed). In fact the child - * uses twice as much CPU time. - */ - start_time = time(NULL); - for (;;) { - if (times(&buf2) == (clock_t)-1) { - tst_resm(TFAIL, - "Call to times " - "failed, " - "errno = %d", - errno); - exit(1); - } - end_time = time(NULL); - if ((end_time - start_time) - > 10) { - break; - } - } - exit(0); - } - waitpid(pid2, &status, 0); - if (WEXITSTATUS(status) != 0) { - tst_resm(TFAIL, "Call to times(2) " - "failed in child"); - } - if (times(&buf2) == (clock_t)-1) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, "Call to times failed " - "errno = %d", errno); - fail=1; - } - if (buf1.tms_utime > buf2.tms_utime) { - tst_resm(TFAIL, "Error: parents's " - "user time(%d) before child " - "> parent's user time (%d) " - "after child", - buf1.tms_utime, - buf2.tms_utime); - fail=1; - } - if (buf2.tms_cutime == 0) { - tst_resm(TFAIL, "Error: times() " - "report %d child user " - "time should be > than " - "zero", buf2.tms_cutime); - fail=1; - } - if (buf2.tms_cstime == 0) { - tst_resm(TFAIL, "Error: times() " - "report %d child system time " - "should be > than zero", - buf2.tms_cstime); - fail=1; - } - if (fail == 0) { - tst_resm(TPASS, "%s: Functionality " - "test passed", TCID); - } - - } else { - tst_resm(TPASS, "%s call succeeded", TCID); - } - } - cleanup(); - /*NOTREACHED*/ -} - -/* - * setup() - * performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -c option. - */ - TEST_PAUSE; -} - -/* - * cleanup() - * performs all ONE TIME cleanup for this test at - * completion or premature exit - */ -void -cleanup(void) -{ - /* - * 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(); - /*NOTREACHED*/ -} diff --git a/winsup/testsuite/winsup.api/ltp/truncate01.c b/winsup/testsuite/winsup.api/ltp/truncate01.c deleted file mode 100644 index 1e2931605..000000000 --- a/winsup/testsuite/winsup.api/ltp/truncate01.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: truncate01 - * - * Test Description: - * Verify that, truncate(2) succeeds to truncate a file to a specified - * length. - * - * Expected Result: - * truncate(2) should return a value 0 and the length of the file after - * truncation should be equal to the length it is truncated to. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * truncate01 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * This test should be run by 'non-super-user' only. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TESTFILE "testfile" /* file under test */ -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define BUF_SIZE 256 /* buffer size */ -#define FILE_SIZE 1024 /* test file size */ -#define TRUNC_LEN 256 /* truncation length */ - -const char *TCID="truncate01"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test conditions */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -int exp_enos[]={0}; - -void setup(); /* setup function for the test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat(2) struct contents */ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - off_t file_length; /* test file length */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (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 -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count = 0; - - /* - * Call truncate(2) to truncate a test file to a - * specified length. - */ - TEST(truncate(TESTFILE, TRUNC_LEN)); - - /* check return code of truncate(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, - "truncate(%s, %d) Failed, errno=%d : %s", - TESTFILE, TRUNC_LEN, TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Get the testfile information using - * stat(2). - */ - if (stat(TESTFILE, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, "stat(2) of " - "%s failed, error:%d", - TESTFILE, errno); - /*NOTREACHED*/ - } - stat_buf.st_mode &= ~S_IFREG; - file_length = stat_buf.st_size; - - /* - * Check for expected size of testfile after - * truncate(2) on it. - */ - if (file_length != TRUNC_LEN) { - tst_resm(TFAIL, "%s: Incorrect file " - "size %d, Expected %d", - TESTFILE, file_length, - TRUNC_LEN); - } else { - tst_resm(TPASS, "Functionality of " - "truncate(%s, %d) successful", - TESTFILE, TRUNC_LEN); - } - } else { - tst_resm(TPASS, "%s call succeeded", TCID); - } - } - Tst_count++; /* incr TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - /*NOTREACHED*/ - -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Fill the buffer with some arbitrary data to be written to a file. - * Create a test file under temporary directory and close it - * write arbitrary data into testfile. - */ -void -setup() -{ - int fd, i; /* file handler for testfile */ - int c, c_total = 0; /* no. bytes to be written to file */ - char tst_buff[BUF_SIZE]; /* buffer to hold data */ - - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - /* Fill the test buffer with the known data */ - for (i = 0; i < BUF_SIZE; i++) { - tst_buff[i] = 'a'; - } - - /* Creat a testfile under temporary directory */ - if ((fd = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - /*NOTREACHED*/ - } - - /* Write to the file 1k data from the buffer */ - while (c_total < FILE_SIZE) { - if ((c = write(fd, tst_buff, sizeof(tst_buff))) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - /*NOTREACHED*/ - } else { - c_total += c; - } - } - - /* Close the testfile after writing data into it */ - if (close(fd) == -1) { - tst_brkm(TBROK, cleanup, - "close(%s) Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - /*NOTREACHED*/ - } -} /* End setup() */ - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test directory and testfile created in the setup. - */ -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/truncate02.c b/winsup/testsuite/winsup.api/ltp/truncate02.c deleted file mode 100644 index 4ba802949..000000000 --- a/winsup/testsuite/winsup.api/ltp/truncate02.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Test Name: truncate02 - * - * Test Description: - * Verify that, truncate(2) succeeds to truncate a file to a certain length, - * but the attempt to read past the truncated length will fail. - * - * Expected Result: - * truncate(2) should return a value 0 and the attempt to read past the - * truncated length will fail. In case where the file before truncation was - * shorter, the bytes between the old and new should be all zeroes. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create 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 and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * truncate02 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * This test should be run by 'non-super-user' only. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -#define TESTFILE "testfile" /* file under test */ -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define BUF_SIZE 256 /* buffer size */ -#define FILE_SIZE 1024 /* test file size */ -#define TRUNC_LEN1 256 /* truncation length */ -#define TRUNC_LEN2 512 /* truncation length */ - -const char *TCID="truncate02"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test conditions */ -extern int Tst_count; /* Test Case counter for tst_* routines */ -int fd; /* file descriptor of testfile */ -char tst_buff[BUF_SIZE]; /* buffer to hold testfile contents */ -int exp_enos[]={0}; - -void setup(); /* setup function for the test */ -void cleanup(void) __attribute__((noreturn)); /* cleanup function for the test */ - -int -main(int ac, char **av) -{ - struct stat stat_buf; /* stat(2) struct contents */ - int lc, i; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - off_t file_length2; /* test file length */ - off_t file_length1; /* test file length */ - int rbytes; /* bytes read from testfile */ - int read_len = 0; /* total no. of bytes read from testfile */ - int err_flag = 0; /* error indicator flag */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (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 -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count = 0; - - /* - * Call truncate(2) to truncate a test file to a - * specified length (TRUNC_LEN1). - */ - TEST(truncate(TESTFILE, TRUNC_LEN1)); - - /* check return code of truncate(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, \ - "truncate(%s, %d) Failed, errno=%d : %s", - TESTFILE, TRUNC_LEN1, TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Get the testfile information using - * stat(2). - */ - if (stat(TESTFILE, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, "stat(2) of " - "%s failed after 1st truncate, " - "error:%d", TESTFILE, errno); - /*NOTREACHED*/ - } - file_length1 = stat_buf.st_size; - - /* - * Set the file pointer of testfile to the - * beginning of the file. - */ - if (lseek(fd, 0, SEEK_SET) < 0) { - tst_brkm(TFAIL, cleanup, "lseek(2) on " - "%s failed after 1st truncate, " - "error:%d", TESTFILE, errno); - /*NOTREACHED*/ - } - - /* Read the testfile from the beginning. */ - while ((rbytes = read(fd, tst_buff, \ - sizeof(tst_buff))) > 0) { - read_len += rbytes; - } - - /* - * Execute truncate(2) again to truncate - * testfile to a size TRUNC_LEN2. - */ - TEST(truncate(TESTFILE, TRUNC_LEN2)); - - /* check return code of truncate(2) */ - if (TEST_RETURN == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, "truncate of %s to " - "size %d Failed, errno=%d : %s", - TESTFILE, TRUNC_LEN2, - TEST_ERRNO, - strerror(TEST_ERRNO)); - } - - /* - * Get the testfile information using - * stat(2) - */ - if (stat(TESTFILE, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, "stat(2) of " - "%s failed after 2nd truncate, " - "error:%d", TESTFILE, errno); - /*NOTREACHED*/ - } - file_length2 = stat_buf.st_size; - - /* - * Set the file pointer of testfile to the - * offset TRUNC_LEN1 of testfile. - */ - if (lseek(fd, TRUNC_LEN1, SEEK_SET) < 0) { - tst_brkm(TFAIL, cleanup, "lseek(2) on " - "%s failed after 2nd truncate, " - "error:%d", TESTFILE, errno); - /*NOTREACHED*/ - } - - /* Read the testfile contents till EOF */ - while((rbytes = read(fd, tst_buff, \ - sizeof(tst_buff))) > 0) { - for (i = 0; i < rbytes; i++) { - if (tst_buff[i] != 0) { - err_flag++; - } - } - } - - /* - * Check for expected size of testfile after - * issuing truncate(2) on it. - */ - if ((file_length1 != TRUNC_LEN1) || \ - (file_length2 != TRUNC_LEN2) || \ - (read_len != TRUNC_LEN1) || \ - (err_flag != 0)) { - tst_resm(TFAIL, "Functionality of " - "truncate(2) on %s Failed", - TESTFILE); - } else { - tst_resm(TPASS, \ - "Functionality of truncate(2) " - "on %s successful", TESTFILE); - } - } else { - tst_resm(TPASS, "%s call succeeded", TCID); - } - } - Tst_count++; /* incr. TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - /*NOTREACHED*/ - -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and write some - * data into it. - */ -void -setup() -{ - int i; /* counter variable */ - int wbytes; /* bytes written to testfile */ - int write_len = 0; /* total no. of bytes written to testfile */ - - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - - /* Fill the test buffer with the known data */ - for (i = 0; i < BUF_SIZE; i++) { - tst_buff[i] = 'a'; - } - - /* Creat a testfile and write some data into it */ - if ((fd = open(TESTFILE, O_RDWR|O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - /*NOTREACHED*/ - } - - /* Write to the file 1k data from the buffer */ - while (write_len < FILE_SIZE) { - if ((wbytes = write(fd, tst_buff, sizeof(tst_buff))) <= 0) { - tst_brkm(TBROK, cleanup, - "write(2) on %s Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } else { - write_len += wbytes; - } - } -} /* End setup() */ - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Close the temporary file opened for reading/writing. - * Remove the test directory and testfile created in the setup. - */ -void -cleanup() -{ - /* - * print timing stats if that option was specified. - */ - TEST_CLEANUP; - - /* Close the testfile after writing data into it */ - if (close(fd) == -1) { - tst_brkm(TFAIL, NULL, - "close(%s) Failed, errno=%d : %s", - TESTFILE, 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/ulimit01.c b/winsup/testsuite/winsup.api/ltp/ulimit01.c deleted file mode 100644 index c3f09fba3..000000000 --- a/winsup/testsuite/winsup.api/ltp/ulimit01.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const 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 */ - const 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/umask02.c b/winsup/testsuite/winsup.api/ltp/umask02.c deleted file mode 100644 index 9a1c61c53..000000000 --- a/winsup/testsuite/winsup.api/ltp/umask02.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * umask02.c - * - * DESCRIPTION - * Check that umask changes the mask, and that the previous - * value of the mask is returned correctly for each value. - * - * ALGORITHM - * For each mask value (9 bits) set mask, and check that the return - * corresponds to the previous value set. - * - * USAGE: - * umask02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions - * None - */ - -#include -#include "test.h" -#include "usctest.h" - -const char *TCID = "umask02"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int argc, char **argv) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - int uret = 0, i, mskval = 0000; - - /* parse standard options */ - if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != - (char *) NULL) { - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); - - /* Check for looping state if -i option is given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - for (umask(++mskval), i = 1; mskval < 01000; - uret = umask(++mskval), i++) { - if ((uret != mskval - 1) && (mskval != 0000)) { - tst_brkm(TBROK, cleanup, "bad mask value " - "returned"); - /*NOTREACHED*/ - } else { - tst_resm(TPASS, "umask(%d) susuccessfully " - "returned %d.", mskval, uret); - } - } - mskval = 0000; - uret = 0; - tst_resm(TINFO, "end of loop %d\n", lc); - } - cleanup(); - /*NOTREACHED*/ -} - -/* - * setup() - * performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -c option. - */ - TEST_PAUSE; -} - -/* - * cleanup() - * performs all ONE TIME cleanup for this test at - * completion or premature exit - */ -void -cleanup(void) -{ - /* - * 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(); - /*NOTREACHED*/ -} diff --git a/winsup/testsuite/winsup.api/ltp/umask03.c b/winsup/testsuite/winsup.api/ltp/umask03.c deleted file mode 100644 index 341da7507..000000000 --- a/winsup/testsuite/winsup.api/ltp/umask03.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * umask01.c - * - * DESCRIPTION - * Check that umask changes the mask, and that the previous - * value of the mask is returned correctly for each value. - * - * ALGORITHM - * For each mask value (9 bits) set mask, and check that the return - * corresponds to the previous value set. - * - * USAGE: - * umask01 [-c n] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions - * None - */ - -#include "test.h" -#include "usctest.h" -#include -#include -#include - -const char *TCID = "umask01"; -int TST_TOTAL = 1; -extern int Tst_count; - -char filname[40]; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int -main(int argc, char **argv) -{ - int lc; - const char *msg; - - struct stat statbuf; - unsigned mskval = 0000; - int fildes, i; - unsigned low9mode; - - /* parse standard options */ - if ((msg = parse_opts(argc, argv, (option_t *) NULL, NULL)) - != (char *) NULL) { - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); /* global setup */ - - /* check looping state if -i option is given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - for (umask(mskval = 0077), i = 1; mskval < 01000; - i++, umask(++mskval)) { - unlink(filname); - if ((fildes = creat(filname, 0777)) == -1) { - tst_resm(TBROK, "cannot create " - "file with mskval 0%o %d", - mskval, mskval); - } else { - if (fstat(fildes, &statbuf) != 0) { - tst_resm(TBROK, "cannot fstat file"); - } else { - low9mode = statbuf.st_mode & 0777; - if (low9mode != (~mskval & 0777)) { - tst_brkm(TBROK, cleanup, - "got %0 expected %o" - "mask didnot take", - low9mode, - (~mskval & 0777)); - /*NOTREACHED*/ - } else { - tst_resm(TPASS, "Test " - "condition: %d, umask: " - "0%o", i, mskval); - } - } - } - close(fildes); - } - } - cleanup(); - /*NOTREACHED*/ -} - -/* - * 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 contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* make temp dir and cd to it */ - tst_tmpdir(); - - sprintf(filname, "umask2.%d", getpid()); -} - -/* - * 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; - - /* - * cleanup the temporary files and the temporary directory - */ - unlink(filname); - tst_rmdir(); - - /* - * exit with return code appropriate for results - */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/uname01.c b/winsup/testsuite/winsup.api/ltp/uname01.c deleted file mode 100644 index 36b166786..000000000 --- a/winsup/testsuite/winsup.api/ltp/uname01.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * 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 -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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 deleted file mode 100644 index 3aae0cf0d..000000000 --- a/winsup/testsuite/winsup.api/ltp/unlink05.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); -void create_file(); - - - -const 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 */ - const 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 deleted file mode 100644 index a62a268c0..000000000 --- a/winsup/testsuite/winsup.api/ltp/unlink06.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void create_file(); -void cleanup(void) __attribute__((noreturn)); - - -const 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 */ - const 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 deleted file mode 100644 index 133109621..000000000 --- a/winsup/testsuite/winsup.api/ltp/unlink07.c +++ /dev/null @@ -1,328 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include /* for PATH_MAX */ -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - -extern char *get_high_address(); - -const 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 { - const char *pathname; - const 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 */ - const char *msg; /* message returned from parse_opts */ - const char *fname; - const 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/unlink08.c b/winsup/testsuite/winsup.api/ltp/unlink08.c deleted file mode 100644 index e793b46f2..000000000 --- a/winsup/testsuite/winsup.api/ltp/unlink08.c +++ /dev/null @@ -1,432 +0,0 @@ -/* - * 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 : unlink08 - * - * EXECUTED BY : anyone - * - * TEST TITLE : unlink(2) negative testcases - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 3 - * - * 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-3) 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 -#include -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -void setup(); -void cleanup(void) __attribute__((noreturn)); - - - -const char *TCID="unlink08"; /* 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}; - -int unwrite_dir_setup(); -int unsearch_dir_setup(); -int dir_setup(); -int no_setup(); - -struct test_case_t { - const char *pathname; - const char *desc; - int (*setupfunc)(); - int exp_ret; /* -1 means error, 0 means != -1 */ - int exp_errno; -} Test_cases[] = { - { "unwrite_dir/file", "unwritable directory", unwrite_dir_setup, - -1, EACCES}, - { "unsearch_dir/file", "unsearchable directory", unsearch_dir_setup, - -1, EACCES }, -#ifdef linux - { "regdir", "directory", dir_setup, -1, EISDIR}, -#else - { "regdir", "directory", dir_setup, -1, EPERM}, -#endif - - { NULL, NULL, no_setup, -1, 0 } -}; - -/*********************************************************************** - * Main - ***********************************************************************/ -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - const char *fname; - const 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; - - /* - * Call unlink(2) - */ - TEST(unlink(fname)); - - /* check return code */ - if ( TEST_RETURN == -1 ) { - if ( Test_cases[ind].exp_ret == -1 ) { /* neg test */ - 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>) Failed, errno=%d", - desc, TEST_ERRNO); - } - } else { - if ( Test_cases[ind].exp_ret == -1 ) { - tst_resm(TFAIL, - "unlink(<%s>) returned %d, expected -1, errno:%d", - desc, TEST_RETURN, Test_cases[ind].exp_errno); - } - else if ( STD_FUNCTIONAL_TEST ) { - tst_resm(TPASS, - "unlink(<%s>) returned %d", - desc, TEST_RETURN); - } - else - Tst_count++; - Test_cases[ind].setupfunc(1); - } - } - - } /* 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; - int postest = 0; - - /* 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 ( geteuid() == 0 ) { - postest++; - } - - for (ind=0; Test_cases[ind].desc != NULL; ind++ ) { - if ( Test_cases[ind].exp_errno == EACCES && postest ) - Test_cases[ind].exp_ret=0; /* set as a pos test */ - Test_cases[ind].setupfunc(0); - } - -} /* 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 -unwrite_dir_setup(flag) -int flag; -{ - int fd; - - if ( ! flag ) { /* initial setup */ - if (mkdir("unwrite_dir", 0777) == -1 ) { - tst_brkm(TBROK, cleanup, - "mkdir(unwrite_dir, 0777) failed, errno:%d %s", - errno, strerror(errno)); - } - - if ( (fd=creat("unwrite_dir/file", 0777)) == -1 ) { - tst_brkm(TBROK, cleanup, - "creat(unwrite_dir/file, 0777) failed, errno:%d %s", - errno, strerror(errno)); - } - close(fd); - - if ( chmod("unwrite_dir", 0555) == -1 ) { - tst_brkm(TBROK, cleanup, - "chmod(unwrite_dir, 0555) failed, errno:%d %s", - errno, strerror(errno)); - } - } - else { /* resetup */ - if ( chmod("unwrite_dir", 0777) == -1 ) { - tst_brkm(TBROK, cleanup, - "chmod(unwrite_dir, 0777) failed, errno:%d %s", - errno, strerror(errno)); - } - - if ( (fd=creat("unwrite_dir/file", 0777)) == -1 ) { - tst_brkm(TBROK, cleanup, - "creat(unwrite_dir/file, 0777) failed, errno:%d %s", - errno, strerror(errno)); - } - close(fd); - - if ( chmod("unwrite_dir", 0555) == -1 ) { - tst_brkm(TBROK, cleanup, - "chmod(unwrite_dir, 0555) failed, errno:%d %s", - errno, strerror(errno)); - } - } - return 0; -} - -/****************************************************************** - * - ******************************************************************/ -int -unsearch_dir_setup(flag) -int flag; -{ - int fd; - - if ( ! flag ) { /* initial setup */ - if (mkdir("unsearch_dir", 0777) == -1 ) { - tst_brkm(TBROK, cleanup, - "mkdir(unsearch_dir, 0777) failed, errno:%d %s", - errno, strerror(errno)); - } - - if ( (fd=creat("unsearch_dir/file", 0777)) == -1 ) { - tst_brkm(TBROK, cleanup, - "creat(unsearch_dir/file, 0777) failed, errno:%d %s", - errno, strerror(errno)); - } - close(fd); - - if ( chmod("unsearch_dir", 0666) == -1 ) { - tst_brkm(TBROK, cleanup, - "chmod(unsearch_dir, 0666) failed, errno:%d %s", - errno, strerror(errno)); - } - } - else { /* resetup */ - if ( chmod("unsearch_dir", 0777) == -1 ) { - tst_brkm(TBROK, cleanup, - "chmod(unsearch_dir, 0777) failed, errno:%d %s", - errno, strerror(errno)); - } - - if ( (fd=creat("unsearch_dir/file", 0777)) == -1 ) { - tst_brkm(TBROK, cleanup, - "creat(unsearch_dir/file, 0777) failed, errno:%d %s", - errno, strerror(errno)); - } - close(fd); - - if ( chmod("unsearch_dir", 0666) == -1 ) { - tst_brkm(TBROK, cleanup, - "chmod(unsearch_dir, 0666) failed, errno:%d %s", - errno, strerror(errno)); - } - } - return 0; -} - -/****************************************************************** - * - ******************************************************************/ -int -dir_setup(flag) -int flag; -{ - if (mkdir("regdir", 0777) == -1 ) { - tst_brkm(TBROK, cleanup, - "mkdir(unwrite_dir, 0777) failed, errno:%d %s", - errno, strerror(errno)); - } - return 0; -} - -/****************************************************************** - * - ******************************************************************/ -int -no_setup(flag) -int flag; -{ - return 0; -} diff --git a/winsup/testsuite/winsup.api/ltp/vfork01.c b/winsup/testsuite/winsup.api/ltp/vfork01.c deleted file mode 100644 index 2792ce08b..000000000 --- a/winsup/testsuite/winsup.api/ltp/vfork01.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Name: vfork01 - * - * Test Description: - * Fork a process using vfork() and verify that, the attribute values like - * euid, ruid, suid, egid, rgid, sgid, umask, inode and device number of - * root and current working directories are same as that of the parent - * process. - * - * Expected Result: - * The attribute values like euid, ruid, suid, egid, rgid, sgid, umask, inode - * and device number of root and current working directory of the parent and - * child processes should be equal. - * - * Algorithm: - * 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, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * - * Usage: - * vfork01 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * None. - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -const char *TCID="vfork01"; /* 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}; - -/* Variables to hold parent/child eff/real/saved uid/gid values */ -uid_t Peuid, Ceuid, Csuid, Psuid, Pruid, Cruid; -gid_t Pegid, Cegid, Psgid, Csgid, Prgid, Crgid; -mode_t Pumask,Cumask; - -char Pcwd_buf [PATH_MAX], Ccwd_buf [PATH_MAX]; -char *Pcwd, *Ccwd; /* - * pathname of working directory of - * child/parent process. - */ -/* stat structure to hold directory/inode information for parent/child */ -struct stat StatPbuf; -struct stat StatCbuf; -struct stat Stat_cwd_Pbuf; -struct stat Stat_cwd_Cbuf; - -void setup(); /* Main setup function of test */ -void cleanup() __attribute__((noreturn));/* cleanup function for the test */ - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - pid_t cpid; /* process id of the child process */ - int exit_status; /* exit status of child process */ - - /* Parse standard options given to run the test. */ - msg = parse_opts(ac, av, (option_t *) NULL, NULL); - if (msg != (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 -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Reset Tst_count in case we are looping. */ - Tst_count=0; - - /* - * Call vfork(2) to create a child process without - * fully copying the address space of parent. - */ - TEST(vfork()); - - /* check return code of vfork() */ - if ((cpid = TEST_RETURN) == -1) { - TEST_ERROR_LOG(TEST_ERRNO); - tst_resm(TFAIL, "vfork() Failed, errno=%d : %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - } else if (cpid == 0) { /* Child process */ - /* - * Perform functional verification if test - * executed without (-f) option. - */ - if (STD_FUNCTIONAL_TEST) { - /* - * Get the euid, ruid, egid, rgid, umask value - * and the current working directory of the - * child process - */ -#if (linux) - if (getresuid(&Cruid, &Ceuid, &Csuid) < 0) { - tst_resm(TFAIL, "getresuid() fails to " - "get real/eff./saved uid of " - "child process"); - _exit(1); - } - - if (getresgid(&Crgid, &Cegid, &Csgid) < 0) { - tst_resm(TFAIL, "getresgid() fails to " - "get real/eff./saved gid of " - "child process"); - _exit(1); - } -#else - Cruid = getuid (); - Ceuid = geteuid (); - Csuid = 0; - Crgid = getgid (); - Cegid = getegid (); - Csgid = 0; -#endif - /* - * Get the file mode creation mask value of - * child process by setting value zero and - * restore the previous mask value. - */ - Cumask = umask(0); - - /* - * Restore the process mask of child to - * previous value. - */ - umask(Cumask); - - /* - * Get the pathname of current working - * directory for the child process. - */ - if ((Ccwd = (char *)getcwd(Ccwd_buf, \ - BUFSIZ)) == NULL) { - tst_resm(TFAIL, "getcwd failed for the " - "child process"); - _exit(1); - } - - /* - * Get the device number and the inode - * number of "/" directory for the child - * process. - */ - if (stat("/", &StatCbuf) < 0) { - tst_resm(TFAIL, "stat(2) failed to get " - "info. of'/' in the child " - "process"); - _exit(1); - } - - /* - * Get the device/inode number of "." - * (working directory) for the child process. - */ - if (stat(Ccwd, &Stat_cwd_Cbuf) < 0) { - tst_resm(TFAIL, "stat(2) failed to get " - "info. of working irectory in " - "the child"); - _exit(1); - } - - /* Now, do the actual comparision */ - if (Peuid != Ceuid || Pegid != Cegid || \ - Psuid != Csuid || Psgid != Csgid || \ - Pruid != Cruid || Prgid != Crgid || \ - Pumask != Cumask) { - tst_resm(TFAIL, "Arribute values of " - "parent and child don't match"); - _exit(1); - } else { - tst_resm(TINFO, "Arribute values of " - "parent and child match"); - } - - /* Check for the same working directories */ - if (strcmp(Pcwd, Ccwd) != 0) { - tst_resm(TFAIL, "Working directories " - "of parent and child don't " - "match"); - _exit(1); - } else { - tst_resm(TINFO, "Working directories " - "of parent and child match"); - } - - /* - * Check for the same device/inode number of - * '/' directory. - */ - if ((StatPbuf.st_ino != StatCbuf.st_ino) || \ - (StatPbuf.st_dev != StatCbuf.st_dev)) { - tst_resm(TFAIL, "Device/inode number " - "of parent and childs '/' " - " don't match"); - _exit(1); - } else { - tst_resm(TINFO, "Device/inode number " - "of parent and childs '/' " - "match"); - } - - /* - * Check for the same device and inode number - * of "." (current working directory. - */ - if ((Stat_cwd_Pbuf.st_ino != \ - Stat_cwd_Cbuf.st_ino) || \ - (Stat_cwd_Pbuf.st_dev != \ - Stat_cwd_Cbuf.st_dev)) { - tst_resm(TFAIL, "Device/inode number " - "of parent and childs '.' " - "don't match"); - _exit(1); - } else { - tst_resm(TINFO, "Device/inode number " - "of parent and childs '.' " - "match"); - } - - /* - * Exit with normal exit code if everything - * fine - */ - _exit(0); - } - } else { /* parent process */ - /* - * Let the parent process wait till child completes - * its execution. - */ - wait(&exit_status); - - /* Check for the exit status of child process */ - if (WEXITSTATUS(exit_status) == 0) { - tst_resm(TPASS, \ - "Call of vfork() successful"); - } else if (WEXITSTATUS(exit_status) == 1) { - tst_resm(TFAIL, \ - "Child process exited abnormally"); - } - } - Tst_count++; /* incr. TEST_LOOP counter */ - } /* End for TEST_LOOPING */ - - /* Call cleanup() to undo setup done for the test. */ - cleanup(); - /*NOTREACHED*/ - -} /* End main */ - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * This function gets real/effective/saved uid/gid, umask, the device/inode - * number of '/' and current working directory for the parent process. - */ -void -setup() -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; - - /* - * Get the euid, ruid, egid, rgid, umask value - * and the current working directory of the parent process. - */ -#if (linux) - if (getresuid(&Pruid, &Peuid, &Psuid) < 0) { - tst_brkm(TFAIL, cleanup, "getresuid() fails to get " - "real/eff./saved uid of parent"); - } - - if (getresgid(&Prgid, &Pegid, &Psgid) < 0) { - tst_brkm(TFAIL, cleanup, "getresgid() fails to get " - "real/eff./saved gid of parent"); - } -#else - Pruid = getuid (); - Peuid = geteuid (); - Psuid = 0; - Prgid = getgid (); - Pegid = getegid (); - Psgid = 0; -#endif - /* Get the process file mode creation mask by setting value 0 */ - Pumask = umask(0); - umask(Pumask); /* - * Restore the mask value of the - * process. - */ - /* - * Get the pathname of current working directory of the parent - * process. - */ - if ((Pcwd = (char *) getcwd(Pcwd_buf, BUFSIZ)) == NULL) { - tst_brkm(TFAIL, cleanup, - "getcwd failed for the parent process"); - } - - /* - * Get the device and inode number of root directory for the - * parent process. - */ - if (stat("/", &StatPbuf) == -1) { - tst_brkm(TFAIL, cleanup, "stat(2) failed to get info. of '/' " - "in parent process"); - } - - /* - * Get the device number and the inode number of "." (current- - * working directory) for the parent process. - */ - if (stat(Pcwd, &Stat_cwd_Pbuf) < 0) { - tst_brkm(TFAIL, cleanup, "stat(2) failed to get info. of " - "working directory in parent process"); - } -} /* End setup() */ - -/* - * void - * 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/wait02.c b/winsup/testsuite/winsup.api/ltp/wait02.c deleted file mode 100644 index a7de67a28..000000000 --- a/winsup/testsuite/winsup.api/ltp/wait02.c +++ /dev/null @@ -1,230 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/wait401.c b/winsup/testsuite/winsup.api/ltp/wait401.c deleted file mode 100644 index 51f71da55..000000000 --- a/winsup/testsuite/winsup.api/ltp/wait401.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * wait401.c - * - * DESCRIPTION - * wait401 - check that a call to wait4() correctly waits for a child - * process to exit - * - * ALGORITHM - * loop if that option was specified - * fork a child. - * issue the system call - * check the return value - * if return value == -1 - * issue a FAIL message, break remaining tests and cleanup - * if we are doing functional testing - * issue a PASS message if the wait4 call returned the child's pid - * else - * issue a FAIL message - * call cleanup - * - * USAGE: - * wait401 [-c n] [-f] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions - * none - */ - -#include "test.h" -#include "usctest.h" - -#include -#define _USE_BSD -#include -#include -#include - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID= "wait401()"; -int TST_TOTAL = 1; -extern int Tst_count; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - pid_t pid; - int status = 1; - struct rusage *rusage = NULL; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL) { - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - } - - setup(); /* global setup */ - - /* The following loop checks looping state if -i option given */ - - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - /* - * Allocate some space for the rusage structure - */ - - if ((rusage = (struct rusage *)malloc(sizeof(struct rusage))) - == NULL) { - tst_brkm(TBROK, cleanup, "malloc() failed"); - } - - pid = fork(); - - if (pid == -1) { - tst_brkm(TBROK, cleanup, "fork() failed"); - } - - if (pid == 0) { /* this is the child */ - /* - * sleep for a moment to let us do the test - */ - sleep(1); - exit(0); - } else { /* this is the parent */ - - /* call wait4 with the TEST() macro */ - TEST(wait4(pid, &status, 0, rusage)); - } - - if (TEST_RETURN == -1) { - tst_brkm(TFAIL, cleanup, "%s call failed - errno = %d " - ": %s", TCID, TEST_ERRNO, strerror(TEST_ERRNO)); - } - - if (STD_FUNCTIONAL_TEST) { - /* - * The return from this call should be non-zero. - */ - if (WIFEXITED(status) == 0) { - tst_brkm(TFAIL, cleanup, "%s call succeeded but " - "WIFEXITED() did not return expected value " - "- %d", TCID, WIFEXITED(status)); - } else if (TEST_RETURN != pid) { - tst_resm(TFAIL, "%s did not return the " - "expected value. %d", TCID, - TEST_RETURN); - } else { - - tst_resm(TPASS, "Received child pid as expected."); - } - } - tst_resm(TPASS, "%s call succeeded", TCID); - - /* - * Clean up things in case we are looping. - */ - free(rusage); - rusage = NULL; - } - - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all the ONE TIME setup for this test. - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified */ - TEST_PAUSE; -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup(void) -{ - /* - * 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(); -} - diff --git a/winsup/testsuite/winsup.api/ltp/wait402.c b/winsup/testsuite/winsup.api/ltp/wait402.c deleted file mode 100644 index 30f7500ac..000000000 --- a/winsup/testsuite/winsup.api/ltp/wait402.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * wait402.c - * - * DESCRIPTION - * wait402 - check for ECHILD errno when using an illegal pid value - * - * ALGORITHM - * loop if that option was specified - * issue the system call with an illegal pid value - * check the errno value - * issue a PASS message if we get ECHILD - * otherwise, the tests fails - * issue a FAIL message - * break any remaining tests - * call cleanup - * - * USAGE: - * wait402 [-c n] [-e] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions - * none - */ - -#include "test.h" -#include "usctest.h" - -#include -#define _USE_BSD -#include -#include -#include - -/* - * See the Makefile for comments about the following preprocessor code. - */ -#if defined (__CYGWIN__) -#define PID_MAX 0xfffffffd -#else -#ifndef _LTP_TASKS_H -#include /* for PID_MAX value - new */ -#else -#include /* for PID_MAX value - old */ -#endif -#endif - -void cleanup(void) __attribute__((noreturn)); -void setup(void); - -const char *TCID= "wait402()"; -int TST_TOTAL = 1; -extern int Tst_count; - -int exp_enos[] = {10, 0}; - -int -main(int ac, char **av) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - pid_t pid; - pid_t epid = PID_MAX + 1; - int status = 1; - struct rusage *rusage=NULL; - - /* parse standard options */ - if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL) { - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - } - - setup(); /* global setup */ - - /* The following loop checks looping state if -i option given */ - - for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - - /* - * Allocate some space for the rusage structure. - */ - - if ((rusage = (struct rusage *)malloc(sizeof(struct rusage))) - == NULL) { - tst_brkm(TBROK, cleanup, "malloc() failed"); - } - - pid = fork(); - - if (pid == -1) { - tst_brkm(TBROK, cleanup, "fork() failed"); - } - - if (pid == 0) { /* this is the child */ - /* - * sleep for a moment to let us do the test - */ - sleep(1); - exit(0); - } else { /* this is the parent */ - /* - * call wait4 with the TEST() macro. epid is set - * to an illegal positive value. This should give - * an ECHILD error. - */ - TEST(wait4(epid, &status, 0, rusage)); - } - - if (TEST_RETURN == 0) { - tst_brkm(TFAIL, cleanup, "call failed to produce expected error - errno = %d - %s", TEST_ERRNO, strerror(TEST_ERRNO)); - } - - TEST_ERROR_LOG(TEST_ERRNO); - - switch (TEST_ERRNO) { - case ECHILD: - tst_resm(TPASS, "received expected failure - errno = %d - %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - break; - default: - tst_brkm(TFAIL, cleanup, "call failed to produce expected " - "error - errno = %d - %s", TEST_ERRNO, - strerror(TEST_ERRNO)); - } - - /* - * Clean up things in case we are looping. - */ - if (pid > 0) { - wait4(pid, &status, 0, rusage); - } - free(rusage); - rusage = NULL; - } - - cleanup(); - - /*NOTREACHED*/ -} - -/* - * setup() - performs all the ONE TIME setup for this test. - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Set up the expected error numbers for -e option */ - TEST_EXP_ENOS(exp_enos); - - /* Pause if that option was specified */ - TEST_PAUSE; -} - -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void -cleanup(void) -{ - /* - * 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(); -} - diff --git a/winsup/testsuite/winsup.api/ltp/write01.c b/winsup/testsuite/winsup.api/ltp/write01.c deleted file mode 100644 index 355190af6..000000000 --- a/winsup/testsuite/winsup.api/ltp/write01.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include "test.h" -#include "usctest.h" - -extern void setup(); -extern void cleanup(); - - - -const 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 */ - const 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/ltp/write02.c b/winsup/testsuite/winsup.api/ltp/write02.c deleted file mode 100644 index a5675bd6d..000000000 --- a/winsup/testsuite/winsup.api/ltp/write02.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * write02.c - * - * DESCRIPTION - * Basic functionality test: does the return from write match the count - * of the number of bytes written. - * - * - * ALGORITHM - * Create a file and write some bytes out to it. - * Check the return count against the number returned. - * - * USAGE: - * write02 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions - * None - */ - -#include -#include "test.h" -#include "usctest.h" -#include - -const char *TCID = "write02()"; -int TST_TOTAL = 1; -extern int Tst_count; - -void cleanup(void) __attribute__ ((noreturn)); -void setup(void); - -char pfiln[40] = ""; - -int -main(int argc, char **argv) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - int cwrite; - int fild; - int iws; - int badcount = 0; - char pwbuf[BUFSIZ + 1]; - - /* parse standard options */ - if ((msg = parse_opts(argc, argv, (option_t *) NULL, NULL))) { - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - setup(); /* global setup for test */ - - /* The following loop checks looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - tst_resm(TINFO, "Block 1: test to see write() returns proper " - "write count"); - - for (iws = 0; iws < BUFSIZ; iws++) { - pwbuf[iws] = 'A' + (iws % 26); - } - pwbuf[BUFSIZ] = '\n'; - - if ((fild = creat(pfiln, 0777)) == -1) { - tst_brkm(TBROK, cleanup, "Can't creat Xwrit"); - /*NOTREACHED*/ - } - for (iws = BUFSIZ; iws > 0; iws--) { - if ((cwrite = write(fild, pwbuf, iws)) != iws) { - TEST_ERROR_LOG(errno); - badcount++; - tst_resm(TINFO, "bad write count"); - } - } - if (badcount != 0) { - tst_resm(TFAIL, "write() FAILED to return proper cnt"); - } else { - tst_resm(TPASS, "write() PASSED"); - } - tst_resm(TINFO, "block 1 passed"); - close(fild); - } - cleanup(); - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - umask(0); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* make a temp directory and cd to it */ - tst_tmpdir(); - - sprintf(pfiln, "./write1.%d", getpid()); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at completion or - * premature exit. - */ -void -cleanup(void) -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - unlink(pfiln); - - /* Remove tmp dir and all files in it */ - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); -} diff --git a/winsup/testsuite/winsup.api/ltp/write03.c b/winsup/testsuite/winsup.api/ltp/write03.c deleted file mode 100644 index 7d6f1f945..000000000 --- a/winsup/testsuite/winsup.api/ltp/write03.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * NAME - * write03.c - * - * DESCRIPTION - * Testcase to check that write(2) doesn't corrupt a file when it fails - * - * ALGORITHM - * Create a file for writing, write 100 bytes to it. Then make write(2) - * fail with some erroneous parameter, close the fd. Then reopen the - * file in RDONLY mode, and read the contents of the file. Compare the - * buffers, to see whether they are same. - * - * USAGE: - * write03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions - * NONE - */ - -#include -#include -#include -#include -#include - -/* 0 terminated list of expected errnos */ -int exp_enos[] = {14,0}; - -const char *TCID = "write03"; -int TST_TOTAL = 1; -extern int Tst_count; - -void setup(void); -void cleanup(void) __attribute__((noreturn)); - -int fd = -1; -char filename[100]; - -int -main(int argc, char **argv) -{ - int lc; /* loop counter */ - const char *msg; /* message returned from parse_opts */ - - char wbuf[BUFSIZ], rbuf[BUFSIZ]; - - /* parse standard options */ - if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != - (char *)NULL) { - tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); - /*NOTREACHED*/ - } - - /* global setup */ - setup(); - - /* The following loop checks looping state if -i option given */ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* reset Tst_count in case we are looping */ - Tst_count = 0; - - tst_resm(TINFO, "Enter Block 1: test to check if write " - "corrupts the file when write fails"); - - fd = creat(filename, 0644); - if (fd < 0) { - tst_resm(TBROK, "creating a new file failed"); - cleanup(); - /*NOTREACHED*/ - } - - (void)memset(wbuf, '0', 100); - - if (write(fd, wbuf, 100) == -1) { - tst_resm(TFAIL, "failed to write to %s", filename); - cleanup(); - /*NOTREACHED*/ - } - - if (write(fd, (void *)-1, 100) != -1) { - tst_resm(TFAIL, "write(2) failed to fail"); - cleanup(); - /*NOTREACHED*/ - } - TEST_ERROR_LOG(errno); - close(fd); - fd = -1; - - if ((fd = open(filename, O_RDONLY)) == -1) { - tst_resm(TBROK, "open(2) failed, errno: %d", errno); - cleanup(); - /*NOTREACHED*/ - } - - if (read(fd, rbuf, 100) == -1) { - tst_resm(TBROK, "read(2) failed, errno: %d", errno); - cleanup(); - /*NOTREACHED*/ - } - - if (memcmp(wbuf, rbuf, 100) == 0) { - tst_resm(TPASS, "failure of write(2) didnot corrupt " - "the file"); - } else { - tst_resm(TFAIL, "failure of write(2) corrupted the " - "file"); - } - tst_resm(TINFO, "Exit block 1"); - } - cleanup(); - /*NOTREACHED*/ -} - -/* - * setup() - performs all ONE TIME setup for this test - */ -void -setup(void) -{ - /* capture signals */ - tst_sig(FORK, DEF_HANDLER, cleanup); - - /* Set up the expected error numbers for -e option */ - TEST_EXP_ENOS(exp_enos); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - /* Create a unique temporary directory and chdir() to it. */ - tst_tmpdir(); - - sprintf(filename, "./write03.%d", getpid()); -} - -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit - */ -void -cleanup(void) -{ - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ - TEST_CLEANUP; - - if (fd >= 0) - close (fd); - - unlink(filename); - tst_rmdir(); - - /* exit with return code appropriate for results */ - tst_exit(); - /*NOTREACHED*/ -} diff --git a/winsup/testsuite/winsup.api/mmaptest01.c b/winsup/testsuite/winsup.api/mmaptest01.c deleted file mode 100644 index 99a7d2ef1..000000000 --- a/winsup/testsuite/winsup.api/mmaptest01.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - Copyright 2001 Free Software Foundation, Inc. - Written by Michael Chastain, - Changes by Corinna Vinschen, : - - Using mkstemp to generate filenames. - - Adding tests - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - This program demonstrates a bug in cygwin's mmap. - I open one file, mmap it, and close it. - I open a different file, mmap it, and close it. - - The second file re-uses the file handle (which is OK), - but then it re-uses the buffer as well! Ouch! - - This bug occurs on cygwin1.dll dated 2001-01-31. - It causes gnu cpp to screw up its include file buffers. - - Compile with "gcc -o y1 y1.c". - - Output from a bad cygwin1.dll: - - y1.txt: 3 0x4660000 y1 y1 y1 y1 y1 y1 y1 - y2.txt: 3 0x4660000 y1 y1 y1 y1 y1 y1 y1 - - Output from a good cygwin1.dll: - - y1.txt: 3 0x14060000 y1 y1 y1 y1 y1 y1 y1 - y2.txt: 3 0x14070000 y2 y2 y2 y2 y2 y2 y2 - - Output from Red Hat Linux 7: - - y1.txt: 3 0x40017000 y1 y1 y1 y1 y1 y1 y1 - y2.txt: 3 0x40018000 y2 y2 y2 y2 y2 y2 y2 - */ - -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -const char *TCID = "mmaptest01"; /* Test program identifier. */ -int TST_TOTAL = 7; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -/* some systems have O_BINARY and some do not */ -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -/* filler for file 1 */ -char const line1 [] = "y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1\n"; -#define size1 (sizeof(line1) - 1) -#define count1 ((4096 / size1) + 1) - -/* filler for file 2 */ -char const line2 [] = "y2 y2 y2 y2 y2 y2 y2 y2 y2 y2 y2 y2 y2 y2 y2 y2 y2\n"; -#define size2 (sizeof(line2) - 1) -#define count2 ((4096 / size2) + 1) - -int main () -{ - char fnam1[32]; - char fnam2[32]; - - int fd1; - char * buf1; - - int fd2; - char * buf2; - - char buf3[20]; - - unsigned i; - - strcpy (fnam1, "mmaptest01.1.XXXXXX"); - strcpy (fnam2, "mmaptest01.2.XXXXXX"); - - /* create file 1 */ - //fd1 = open (fnam1, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644); - fd1 = mkstemp (fnam1); - for (i = 0; i < count1; i++) - write (fd1, line1, size1); - close (fd1); - - /* create file 2 */ - //fd2 = open (fnam2, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644); - fd2 = mkstemp (fnam2); - for (i = 0; i < count2; i++) - write (fd2, line2, size2); - close (fd2); - - /* mmap file 1 */ - fd1 = open (fnam1, O_RDONLY | O_BINARY, 0644); - buf1 = mmap (0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd1, 0); - close (fd1); - - /* mmap file 2 */ - fd2 = open (fnam2, O_RDONLY | O_BINARY, 0644); - buf2 = mmap (0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd2, 0); - close (fd2); - - /* the buffers have to be different */ - Tst_count = 0; - tst_resm (buf1 == buf2 || !memcmp (buf1, buf2, 20) ? TFAIL : TPASS, - "mmap uses unique buffers when mapping different already closed files"); - munmap (buf2, 4096); - - /* mmap file 1 twice with MAP_PRIVATE */ - fd2 = open (fnam1, O_RDONLY | O_BINARY, 0644); - buf2 = mmap (0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd2, 0); - close (fd2); - - tst_resm (buf1 == buf2 ? TFAIL : TPASS, - "mmap uses different buffers on MAP_PRIVATE mapping"); - - tst_resm (memcmp (buf1, buf2, 20) ? TFAIL : TPASS, - "two private buffers of the same file are identical"); - - buf1[0] = 0x7f; - tst_resm (!memcmp (buf1, buf2, 20) ? TFAIL : TPASS, - "changes are private in MAP_PRIVATE mappings"); - - munmap (buf1, 4096); - munmap (buf2, 4096); - - /* mmap file 1 twice with MAP_SHARED */ - fd1 = open (fnam1, O_RDWR | O_BINARY, 0644); - buf1 = mmap (0, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd1, 0); - close (fd1); - - fd2 = open (fnam1, O_RDWR | O_BINARY, 0644); - buf2 = mmap (0, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd2, 0); - close (fd2); - - tst_resm (memcmp (buf1, buf2, 20) ? TFAIL : TPASS, - "two shared buffers of the same file are identical"); - - buf1[0] = 0x7f; - tst_resm (memcmp (buf1, buf2, 20) ? TFAIL : TPASS, - "changes are shared between MAP_SHARED mappings of the same file"); - munmap (buf2, 4096); - - fd2 = open (fnam1, O_RDWR | O_BINARY, 0644); - memset (buf3, 0, 20); - read (fd2, buf3, 20); - close (fd2); - - tst_resm (memcmp (buf1, buf3, 20) ? TFAIL : TPASS, - "changes are propagated to the mapped file on MAP_SHARED mapping"); - - munmap (buf1, 4096); - unlink (fnam1); - unlink (fnam2); - tst_exit (); -} - diff --git a/winsup/testsuite/winsup.api/mmaptest02.c b/winsup/testsuite/winsup.api/mmaptest02.c deleted file mode 100644 index bec7c392c..000000000 --- a/winsup/testsuite/winsup.api/mmaptest02.c +++ /dev/null @@ -1,190 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -sigset_t unblock_sigsegv; -jmp_buf r; -size_t pg; - -int fd; - -/* Checks behaviour of anonymous mmap. - - test_1: If we map a 2-page region and unmap its second page, the first page - must remain. - - test_2: If we map a 2-page region and unmap its first page, the second - page must remain. - - test_3: If we map two consecutive 1-page regions and unmap them both with - one munmap, both must go away. -*/ - -void -perror_exit (const char *str, int code) -{ - printf ("%s: %s\n", str, strerror (errno)); - exit (code); -} - -void -anonmap_init () -{ - sigemptyset (&unblock_sigsegv); - sigaddset (&unblock_sigsegv, SIGSEGV); - pg = getpagesize (); - fd = open ("/dev/zero", O_RDWR); -} - -char * -anonmap (size_t size) -{ - return (char *) mmap (0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); -} - -void -anonfree (char *loc, size_t size) -{ - munmap (loc, size); -} - -void -sigsegv (int unused) -{ - sigprocmask (SIG_UNBLOCK, &unblock_sigsegv, 0); - longjmp (r, 1); -} - -int -compare_pointers (const void *a, const void *b) -{ - const char *x = *(const char *const *)a; - const char *y = *(const char *const *)b; - - if (x > y) - return 1; - if (x < y) - return -1; - return 0; -} - -void -test_1 () -{ - char *x = anonmap (pg * 2); - if (x == (char *)MAP_FAILED) - perror_exit ("test 1 mmap", 1); - - signal (SIGSEGV, sigsegv); - if (setjmp (r)) - perror_exit ("test 1 fault", 2); - - x[0] = 1; - x[pg] = 1; - - anonfree (x + pg, pg); - x[0] = 2; - - if (setjmp (r) == 0) - { - x[pg] = 1; - perror_exit ("test 1 no fault", 3); - } -} - -void -test_2 () -{ - char *x = anonmap (pg * 2); - if (x == (char *)MAP_FAILED) - perror_exit ("test 2 mmap", 4); - - signal (SIGSEGV, sigsegv); - if (setjmp (r)) - perror_exit ("test 2 fault", 5); - - x[0] = 1; - x[pg] = 1; - - anonfree (x, pg); - x[pg] = 2; - - if (setjmp (r) == 0) - { - x[0] = 1; - perror_exit ("test 2 no fault", 6); - } -} - -void -test_3 () -{ - char *x[10]; - char *y; - int i; - - /* There's no way to guarantee we get consecutive pages from the OS. The - approach taken here is to allocate ten of them, sort the list, and - look for consecutive pages. */ - for (i = 0; i < 10; i++) - { - x[i] = anonmap (pg); - if (x[i] == (char *)MAP_FAILED) - perror_exit ("test 3 mmap 1", 7); - } - qsort (x, 10, sizeof (char *), compare_pointers); - - y = 0; - for (i = 0; i < 9; i++) - if (x[i] + pg == x[i+1]) - { - y = x[i]; - break; - } - if (y == 0) - { - fputs ("test 3: couldn't get two consecutive pages, giving up\n", stdout); - exit (65); - } - - signal (SIGSEGV, sigsegv); - if (setjmp (r)) - perror_exit ("test 3 fault", 8); - - y[0] = 1; - y[pg] = 1; - - anonfree (y, pg * 2); - - if (setjmp (r) == 0) - { - y[0] = 1; - perror_exit ("test 3 no fault 1", 9); - } - - signal (SIGSEGV, sigsegv); - if (setjmp (r) == 0) - { - y[pg] = 1; - perror_exit ("test 3 no fault 2", 10); - } -} - -int -main () -{ - anonmap_init(); - - test_1(); - test_2(); - test_3(); - - exit(0); -} diff --git a/winsup/testsuite/winsup.api/mmaptest03.c b/winsup/testsuite/winsup.api/mmaptest03.c deleted file mode 100644 index 2af191237..000000000 --- a/winsup/testsuite/winsup.api/mmaptest03.c +++ /dev/null @@ -1,128 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - Checks if mapping of already closed file survives fork() - - Checks if mapping the same region of the same file twice - is done correctly. -*/ - -sigset_t unblock_sigsegv; -jmp_buf r; - -/* filler for file */ -char const line[] = "y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1 y1"; - -void -perror_exit (const char *str) -{ - printf ("%s: %s\n", str, strerror (errno)); - exit (1); -} - -void -sigsegv (int unused) -{ - sigprocmask (SIG_UNBLOCK, &unblock_sigsegv, 0); - longjmp (r, 1); -} - -int -main(int argc, char **argv) -{ - int fd, status; - struct stat statbuf; - volatile char c, *buf1, *buf2; - pid_t pid; - - /* Create data file */ - if ((fd = open("y.txt", O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) - perror_exit ("Can't create data file"); - write (fd, line, sizeof(line) - 1); - close (fd); - - /* Open data file */ - if ((fd = open("y.txt", O_RDONLY)) == -1) - perror_exit ("Can't open data file"); - - if (fstat(fd, &statbuf) < 0) - perror_exit ("fstat failed"); - - if (!statbuf.st_size) - perror_exit ("filesize is 0"); - - if ((buf1 = mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0)) - == MAP_FAILED) - perror_exit ("mmap 1 failed"); - - close(fd); - - /* Open data file a second time */ - if ((fd = open("y.txt", O_RDONLY)) == -1) - perror_exit ("Can't open data file in second run"); - - if ((buf2 = mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0)) - == MAP_FAILED) - perror_exit ("mmap 2 failed"); - - close(fd); - - sigemptyset (&unblock_sigsegv); - sigaddset (&unblock_sigsegv, SIGSEGV); - signal (SIGSEGV, sigsegv); - - if (setjmp (r)) - perror_exit ("SEGV in fork"); - - pid = fork(); - - if (pid == -1) - perror_exit ("fork failed"); - - if (setjmp (r)) - perror_exit (pid ? "SEGV in parent" : "SEGV in child"); - - c = buf1[0]; - c = buf2[0]; - - if (setjmp (r)) - perror_exit (pid ? "SEGV in parent's munmap" : "SEGV in child's munmap"); - - if (munmap((void *) buf1, statbuf.st_size)) - perror_exit (pid ? "munmap failed in parent" : "munmap failed in child"); - - if (setjmp (r) == 0) - { - c = buf1[0]; - perror_exit (pid ? "no SEGV in parent after munmap" : "no SEGV in child after munmap"); - } - - if (setjmp (r)) - perror_exit (pid ? "SEGV in parent after munmap" : "SEGV in child after munmap"); - - c = buf2[0]; - - if (setjmp (r)) - perror_exit (pid ? "SEGV in parent's munmap" : "SEGV in child's munmap"); - - if (munmap((void *) buf2, statbuf.st_size)) - perror_exit (pid ? "munmap failed in parent" : "munmap failed in child"); - - if (pid) - { - waitpid (pid, &status, 0); - unlink ("y.txt"); - if (!WIFEXITED (status) || WEXITSTATUS (status)) - return 1; - } - - return 0; -} diff --git a/winsup/testsuite/winsup.api/mmaptest04.c b/winsup/testsuite/winsup.api/mmaptest04.c deleted file mode 100644 index 52302bae1..000000000 --- a/winsup/testsuite/winsup.api/mmaptest04.c +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -int -main () -{ - char *data, *data2 = NULL, *data3; - int i, pagesize; - int fd; - - pagesize = 65536; //getpagesize(); - - /* - * First, make a file with some known garbage in it. - */ - data = (char *) malloc (pagesize); - if (!data) - exit (1); - for (i = 0; i < pagesize; ++i) - *(data + i) = rand (); - umask (0); - fd = open ("conftestmmap", O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0600); - if (fd < 0) - { - printf ("creat: %d\n", errno); - exit (1); - } - if (write (fd, data, pagesize) != pagesize) - { - printf ("write: %d\n", errno); - exit (1); - } - close (fd); - - /* - * Next, try to mmap the file. - */ - fd = open ("conftestmmap", O_RDWR | O_BINARY); - if (fd < 0) - { - printf ("write: %d\n", errno); - exit (1); - } - if ((data2 = mmap (data2, pagesize, PROT_READ | PROT_WRITE, - MAP_PRIVATE, fd, 0L)) == MAP_FAILED) - { - printf ("mmap: %d\n", errno); - exit (1); - } - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data2 + i)) - { - printf ("check-if: %d\n", errno); - exit (1); - } - - /* - * Finally, make sure that changes to the mapped area - * do not percolate back to the file as seen by read(). - * (This is a bug on some variants of i386 svr4.0.) - */ - for (i = 0; i < pagesize; ++i) - *(data2 + i) = *(data2 + i) + 1; - data3 = (char *) malloc (pagesize); - if (!data3) - { - printf ("malloc2: %d\n", errno); - exit (1); - } - if (read (fd, data3, pagesize) != pagesize) - { - printf ("read: %d\n", errno); - exit (1); - } - for (i = 0; i < pagesize; ++i) - if (*(data + i) != *(data3 + i)) - { - printf ("check-if2: %d\n", errno); - exit (1); - } - if (msync (data2, pagesize, MS_SYNC)) - { - printf ("msync: %d\n", errno); - exit (1); - } - if (munmap (data2, pagesize)) - { - printf ("munmap: %d\n", errno); - exit (1); - } - close (fd); - unlink ("conftestmmap"); - exit (0); -} diff --git a/winsup/testsuite/winsup.api/msgtest.c b/winsup/testsuite/winsup.api/msgtest.c deleted file mode 100644 index e002a7fda..000000000 --- a/winsup/testsuite/winsup.api/msgtest.c +++ /dev/null @@ -1,348 +0,0 @@ -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * Obtained from: $NetBSD: msgtest.c,v 1.7 2002/07/20 08:36:25 grant Exp $ - * $FreeBSD: /repoman/r/ncvs/src/tools/regression/sysvmsg/msgtest.c,v 1.1 2002/08/15 06:34:37 alfred Exp $ - */ - -/* - * Test the SVID-compatible Message Queue facility. - */ - -/* - * CV, 2003-11-17: Add to Cygwin testsuite. - */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -const char *TCID = "msgtest"; /* Test program identifier. */ -int TST_TOTAL = 31; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -void print_msqid_ds (struct msqid_ds *, mode_t); -void sigsys_handler(int); -void sigchld_handler (int); -void cleanup (void); -void receiver (void); - -#define MESSAGE_TEXT_LEN 255 - -/* - * Define it as test_mymsg because we already have struct mymsg and we dont - * want to conflict with it. Also, regression fails when the default mymsg - * struct is used, because mtext[] array is '1', so the passed string cannot - * be processed. - */ -struct test_mymsg { - long mtype; - char mtext[MESSAGE_TEXT_LEN]; -}; - -const char *m1_str = "California is overrated."; -const char *m2_str = "The quick brown fox jumped over the lazy dog."; - -#define MTYPE_1 1 -#define MTYPE_1_ACK 2 - -#define MTYPE_2 3 -#define MTYPE_2_ACK 4 - -int sender_msqid = -1; -pid_t child_pid; - -key_t msgkey; - -int -main(int argc, char *argv[]) -{ - struct sigaction sa; - struct msqid_ds m_ds; - struct test_mymsg m; - sigset_t sigmask; - - Tst_count = 0; - - /* - * Install a SIGSYS handler so that we can exit gracefully if - * System V Message Queue support isn't in the kernel. - */ - sa.sa_handler = sigsys_handler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - if (sigaction(SIGSYS, &sa, NULL) == -1) - tst_brkm (TBROK, cleanup, "sigaction SIGSYS"); - - /* - * Install and SIGCHLD handler to deal with all possible exit - * conditions of the receiver. - */ - sa.sa_handler = sigchld_handler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - if (sigaction(SIGCHLD, &sa, NULL) == -1) - tst_brkm (TBROK, cleanup, "sigaction SIGCHLD"); - - msgkey = ftok("/", 4160); - tst_resm (msgkey == (key_t)-1 ? TFAIL : TPASS, - "ftok(\"/\") returns valid value"); - - /* - * Initialize child_pid to ourselves to that the cleanup function - * works before we create the receiver. - */ - child_pid = getpid(); - - sender_msqid = msgget(msgkey, IPC_CREAT | 0640); - tst_resm (sender_msqid == -1 ? TFAIL : TPASS, "sender calls msgget"); - - tst_resm (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1 ? TFAIL : TPASS, - "msgctl IPC_STAT"); - - print_msqid_ds(&m_ds, 0640); - - m_ds.msg_perm.mode = (m_ds.msg_perm.mode & ~0777) | 0600; - - tst_resm (msgctl(sender_msqid, IPC_SET, &m_ds) == -1 ? TFAIL : TPASS, - "msgctl IPC_SET"); - - bzero(&m_ds, sizeof m_ds); - - tst_resm (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1 ? TFAIL : TPASS, - "msgctl IPC_STAT"); - - tst_resm ((m_ds.msg_perm.mode & 0777) != 0600 ? TFAIL : TPASS, - "IPC_SET of mode holds"); - - print_msqid_ds(&m_ds, 0600); - - switch ((child_pid = fork())) { - case -1: - tst_brkm (TBROK, cleanup, "fork"); - /* NOTREACHED */ - - case 0: - tst_resm (TPASS, "fork"); - receiver(); - break; - - default: - Tst_count += 8; - break; - } - - /* - * Send the first message to the receiver and wait for the ACK. - */ - m.mtype = MTYPE_1; - strcpy(m.mtext, m1_str); - tst_resm (msgsnd(sender_msqid, &m, sizeof(m), 0) == -1 ? TFAIL : TPASS, - "sender: msgsnd 1"); - - tst_resm (msgrcv(sender_msqid, &m, sizeof(m), MTYPE_1_ACK, 0) - != sizeof(m) ? TFAIL : TPASS, "sender: msgrcv 1 ack"); - - print_msqid_ds(&m_ds, 0600); - - /* - * Send the second message to the receiver and wait for the ACK. - */ - m.mtype = MTYPE_2; - strcpy(m.mtext, m2_str); - tst_resm (msgsnd(sender_msqid, &m, sizeof(m), 0) == -1 ? TFAIL : TPASS, - "sender: msgsnd 2"); - - tst_resm (msgrcv(sender_msqid, &m, sizeof(m), MTYPE_2_ACK, 0) - != sizeof(m) ? TFAIL : TPASS, "sender: msgrcv 2 ack"); - - /* - * Suspend forever; when we get SIGCHLD, the handler will exit. - */ - sigemptyset(&sigmask); - (void) sigsuspend(&sigmask); - - /* - * ...and any other signal is an unexpected error. - */ - tst_brkm (TBROK, cleanup, "sender: received unexpected signal"); - exit (1); -} - -void -sigsys_handler(int signo) -{ - - tst_brkm (TBROK, cleanup, - "System V Message Queue support is not present in the kernel"); -} - -void -sigchld_handler(int signo) -{ - struct msqid_ds m_ds; - int cstatus; - - /* - * Reap the child; if it exited successfully, then the test passed! - */ - if (waitpid(child_pid, &cstatus, 0) != child_pid) - tst_brkm (TBROK, cleanup, "waitpid"); - - if (WIFEXITED(cstatus) == 0) - tst_brkm (TBROK, cleanup, "receiver exited abnormally"); - - if (WEXITSTATUS(cstatus) != 0) - tst_brkm (TBROK, cleanup, "receiver exited with status %d", - WEXITSTATUS(cstatus)); - - /* - * If we get here, the child has exited normally, and thus - * we should exit normally too. First, tho, we print out - * the final stats for the message queue. - */ - - tst_resm (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1 ? TFAIL : TPASS, - "msgctl IPC_STAT"); - - print_msqid_ds(&m_ds, 0600); - - cleanup (); -} - -void -cleanup() -{ - - /* - * If we're the sender, and it exists, remove the message queue. - */ - if (child_pid != 0 && sender_msqid != -1) { - tst_resm (msgctl(sender_msqid, IPC_RMID, NULL) == -1 - ? TFAIL : TPASS, "msgctl IPC_RMID"); - } - tst_exit (); -} - -void -print_msqid_ds(struct msqid_ds *mp, mode_t mode) -{ - uid_t uid = geteuid(); - gid_t gid = getegid(); - - printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n", - (int)mp->msg_perm.uid, (int)mp->msg_perm.gid, - (int)mp->msg_perm.cuid, (int)mp->msg_perm.cgid, - mp->msg_perm.mode & 0777); - - printf("qnum %lu, qbytes %lu, lspid %d, lrpid %d\n", - mp->msg_qnum, (u_long)mp->msg_qbytes, mp->msg_lspid, - mp->msg_lrpid); - - printf("stime: %s", ctime(&mp->msg_stime)); - printf("rtime: %s", ctime(&mp->msg_rtime)); - printf("ctime: %s", ctime(&mp->msg_ctime)); - - /* - * Sanity check a few things. - */ - - tst_resm (mp->msg_perm.uid != uid || mp->msg_perm.cuid != uid - ? TFAIL : TPASS, "uid matches"); - - tst_resm (mp->msg_perm.gid != gid || mp->msg_perm.cgid != gid - ? TFAIL : TPASS, "gid matches"); - - tst_resm ((mp->msg_perm.mode & 0777) != mode ? TFAIL : TPASS, - "mode matches"); -} - -void -receiver() -{ - struct test_mymsg m; - int msqid; - - tst_resm ((msqid = msgget(msgkey, 0)) == -1 ? TFAIL : TPASS, - "receiver: msgget"); - - /* - * Receive the first message, print it, and send an ACK. - */ - - tst_resm (msgrcv(msqid, &m, sizeof(m), MTYPE_1, 0) != sizeof(m) - ? TFAIL : TPASS, "receiver: msgrcv 1"); - - printf("%s\n", m.mtext); - tst_resm (strcmp(m.mtext, m1_str) != 0 ? TFAIL : TPASS, - "receiver: message 1 data is correct"); - - m.mtype = MTYPE_1_ACK; - - tst_resm (msgsnd(msqid, &m, sizeof(m), 0) == -1 ? TFAIL : TPASS, - "receiver: msgsnd ack 1"); - - /* - * Receive the second message, print it, and send an ACK. - */ - - tst_resm (msgrcv(msqid, &m, sizeof(m), MTYPE_2, 0) != sizeof(m) - ? TFAIL : TPASS, "receiver: msgrcv 2"); - - printf("%s\n", m.mtext); - tst_resm (strcmp(m.mtext, m2_str) != 0 ? TFAIL : TPASS, - "receiver: message 2 data is correct"); - - m.mtype = MTYPE_2_ACK; - - tst_resm (msgsnd(msqid, &m, sizeof(m), 0) == -1 ? TFAIL : TPASS, - "receiver: msgsnd ack 2"); - - /* Allow parent to receive message before getting SIGCHLD. */ - sleep (1); - exit(0); -} diff --git a/winsup/testsuite/winsup.api/nullgetcwd.c b/winsup/testsuite/winsup.api/nullgetcwd.c deleted file mode 100644 index 25bdf4514..000000000 --- a/winsup/testsuite/winsup.api/nullgetcwd.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include -#include -int -main (int argc, char **argv) -{ - char *cwd = getcwd (NULL, 256); - if (cwd == NULL) - { - fprintf (stderr, "%s: getcwd returns NULL\n", argv[0]); - exit (1); - } - - exit (0); -} - diff --git a/winsup/testsuite/winsup.api/pthread/cancel1.c b/winsup/testsuite/winsup.api/pthread/cancel1.c deleted file mode 100644 index 96ae390ce..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel1.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * File: cancel1.c - * - * Test Synopsis: Test setting cancel state and cancel type. - * - - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - pthread_setcancelstate function - * - pthread_setcanceltype function - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - pthread_create, pthread_self work. - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* ... */ - { - int oldstate; - int oldtype; - - assert(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate) == 0); - assert(oldstate == PTHREAD_CANCEL_ENABLE); /* Check default */ - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - assert(pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) == 0); - assert(pthread_setcancelstate(oldstate, &oldstate) == 0); - assert(oldstate == PTHREAD_CANCEL_DISABLE); /* Check setting */ - - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype) == 0); - assert(oldtype == PTHREAD_CANCEL_DEFERRED); /* Check default */ - assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0); - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - assert(pthread_setcanceltype(oldtype, &oldtype) == 0); - assert(oldtype == PTHREAD_CANCEL_ASYNCHRONOUS); /* Check setting */ - } - - return 0; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()) != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 1000); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print ouput on failure. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - /* ... */ - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/cancel10.c b/winsup/testsuite/winsup.api/pthread/cancel10.c deleted file mode 100644 index 5e0cc6770..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel10.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * File: cancel10.c - * - * Test Synopsis: Test if system is a cancellation point. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_cancel, pthread_setcancelstate - * pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -static int cancelled = 0; - -static void *Thread(void *punused) -{ - while (!cancelled) - Sleep (0); - - system (NULL); - - return NULL; -} - -int main (void) -{ - void * result; - pthread_t t; - - assert (pthread_create (&t, NULL, Thread, NULL) == 0); - assert (pthread_cancel (t) == 0); - cancelled = 1; - assert (pthread_join (t, &result) == 0); - assert (result == PTHREAD_CANCELED); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/cancel11.c b/winsup/testsuite/winsup.api/pthread/cancel11.c deleted file mode 100644 index b6554ed69..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel11.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * File: cancel11.c - * - * Test Synopsis: Test if system is a cancellation point. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_cancel, pthread_setcancelstate - * pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -static void sig_handler(int sig) -{ -} - -static void *Thread(void *punused) -{ - system ("sleep 10"); - - return NULL; -} - -int main (void) -{ - void * result; - pthread_t t; - - signal (SIGINT, sig_handler); - - assert (pthread_create (&t, NULL, Thread, NULL) == 0); - sleep (5); - assert (pthread_cancel (t) == 0); - assert (pthread_join (t, &result) == 0); - assert (result == PTHREAD_CANCELED); - - assert ((void *)signal (SIGINT, NULL) == sig_handler); - - /* Wait until child process has terminated */ - sleep (10); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/cancel12.c b/winsup/testsuite/winsup.api/pthread/cancel12.c deleted file mode 100644 index 12273d676..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel12.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * File: cancel12.c - * - * Test Synopsis: Test if system is a cancellation point. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_cancel, pthread_setcancelstate - * pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -static void sig_handler(int sig) -{ -} - -static void *Thread(void *punused) -{ - signal (SIGINT, sig_handler); - - system ("sleep 5"); - - assert ((void *)signal (SIGINT, NULL) == sig_handler); - - return NULL; -} - -int main (void) -{ - void * result; - pthread_t t; - - assert (pthread_create (&t, NULL, Thread, NULL) == 0); - assert (pthread_join (t, &result) == 0); - assert (result == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/cancel2.c b/winsup/testsuite/winsup.api/pthread/cancel2.c deleted file mode 100644 index 2d99c3414..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel2.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * File: cancel2.c - * - * Test Synopsis: Test SEH or C++ cancel exception handling within - * application exception blocks. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -static pthread_mutex_t waitLock = PTHREAD_MUTEX_INITIALIZER; - -void * -mythread(void * arg) -{ - int result = 0; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - switch (bag->threadnum % 2) - { - case 0: - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - result = 0; - break; - case 1: - assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0); - result = 1; - break; - } - - /* Wait for go from main */ - assert(pthread_mutex_lock(&waitLock) == 0); - assert(pthread_mutex_unlock(&waitLock) == 0); - sched_yield(); - - for (;;) - { - pthread_testcancel(); - } - - return (void *) result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()) != NULL); - assert(pthread_mutex_lock(&waitLock) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - assert(pthread_mutex_unlock(&waitLock) == 0); - - Sleep(500); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_cancel(t[i]) == 0); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - int result = 0; - - assert(pthread_join(t[i], (void **) &result) == 0); - fail = (result != (int) PTHREAD_CANCELED); - if (fail) - { - fprintf(stderr, "Thread %d: started %d: location %d: cancel type %s\n", - i, - threadbag[i].started, - result, - ((result % 2) == 0) ? "ASYNCHRONOUS" : "DEFERRED"); - } - failed |= fail; - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} - diff --git a/winsup/testsuite/winsup.api/pthread/cancel3.c b/winsup/testsuite/winsup.api/pthread/cancel3.c deleted file mode 100644 index 3ac03e4b6..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel3.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * File: cancel3.c - * - * Test Synopsis: Test asynchronous cancelation. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -void * -mythread(void * arg) -{ - int result = ((int)PTHREAD_CANCELED + 1); - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - - /* - * We wait up to 10 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (bag->count = 0; bag->count < 100; bag->count++) - Sleep(100); - - return (void *) result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()) != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_cancel(t[i]) == 0); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - int result = 0; - - /* - * The thread does not contain any cancelation points, so - * a return value of PTHREAD_CANCELED confirms that async - * cancelation succeeded. - */ - assert(pthread_join(t[i], (void **) &result) == 0); - - fail = (result != (int) PTHREAD_CANCELED); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: count %d\n", - i, - threadbag[i].started, - threadbag[i].count); - } - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/cancel4.c b/winsup/testsuite/winsup.api/pthread/cancel4.c deleted file mode 100644 index d6b2ffadf..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel4.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * File: cancel4.c - * - * Test Synopsis: Test cancelation does not occur in deferred - * cancelation threads with no cancelation points. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - pthread_create - * pthread_self - * pthread_cancel - * pthread_join - * pthread_setcancelstate - * pthread_setcanceltype - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -void * -mythread(void * arg) -{ - int result = ((int)PTHREAD_CANCELED + 1); - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0); - - /* - * We wait up to 10 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (bag->count = 0; bag->count < 100; bag->count++) - Sleep(100); - - return (void *) result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()) != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_cancel(t[i]) == 0); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - int result = 0; - - /* - * The thread does not contain any cancelation points, so - * a return value of PTHREAD_CANCELED indicates that async - * cancelation occurred. - */ - assert(pthread_join(t[i], (void **) &result) == 0); - - fail = (result == (int) PTHREAD_CANCELED); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: count %d\n", - i, - threadbag[i].started, - threadbag[i].count); - } - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} - diff --git a/winsup/testsuite/winsup.api/pthread/cancel5.c b/winsup/testsuite/winsup.api/pthread/cancel5.c deleted file mode 100644 index 9dd579543..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel5.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * File: cancel5.c - * - * Test Synopsis: Test calling pthread_cancel from the main thread - * without calling pthread_self() in main. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -void * -mythread(void * arg) -{ - int result = ((int)PTHREAD_CANCELED + 1); - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Set to known state and type */ - - assert(pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == 0); - - assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0); - - /* - * We wait up to 10 seconds, waking every 0.1 seconds, - * for a cancelation to be applied to us. - */ - for (bag->count = 0; bag->count < 100; bag->count++) - Sleep(100); - - return (void *) result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(500); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_cancel(t[i]) == 0); - } - - /* - * Give threads time to run. - */ - Sleep(NUMTHREADS * 100); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - int result = 0; - - /* - * The thread does not contain any cancelation points, so - * a return value of PTHREAD_CANCELED confirms that async - * cancelation succeeded. - */ - assert(pthread_join(t[i], (void **) &result) == 0); - - fail = (result != (int) PTHREAD_CANCELED); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: count %d\n", - i, - threadbag[i].started, - threadbag[i].count); - } - failed = (failed || fail); - } - - assert(!failed); - - /* - * Success. - */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/cancel6.c b/winsup/testsuite/winsup.api/pthread/cancel6.c deleted file mode 100644 index 8f0bdd849..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel6.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * File: cancel6.c - * - * Test Synopsis: Test if pause is a cancellation point. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_cancel, pthread_setcancelstate - * pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -static void *Thread(void *punused) -{ - pause (); - - return NULL; -} - -int main (void) -{ - void * result; - pthread_t t; - - assert (pthread_create (&t, NULL, Thread, NULL) == 0); - assert (pthread_cancel (t) == 0); - assert (pthread_join (t, &result) == 0); - assert (result == PTHREAD_CANCELED); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/cancel7.c b/winsup/testsuite/winsup.api/pthread/cancel7.c deleted file mode 100644 index 7a631f695..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel7.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * File: cancel7.c - * - * Test Synopsis: Test if sleep is a cancellation point. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_cancel, pthread_setcancelstate - * pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -static int has5secsleeped = 0; - -static void *Thread(void *punused) -{ - assert (pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL) == 0); - /* thread should sleep 5 seconds and not get canceled */ - sleep(5); - has5secsleeped = 1; - assert (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) == 0); - /* thread should cancel here */ - sleep (5); - - return NULL; -} - -int main (void) -{ - void * result; - pthread_t t; - - assert (pthread_create (&t, NULL, Thread, NULL) == 0); - assert (pthread_cancel (t) == 0); - assert (pthread_join (t, &result) == 0); - assert (has5secsleeped == 1); - assert (result == PTHREAD_CANCELED); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/cancel8.c b/winsup/testsuite/winsup.api/pthread/cancel8.c deleted file mode 100644 index fb30fd93b..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel8.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * File: cancel8.c - * - * Test Synopsis: Test if usleep is a cancellation point. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_cancel, pthread_setcancelstate - * pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -static int has5secsleeped = 0; - -static void *Thread(void *punused) -{ - assert (pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL) == 0); - /* thread should usleep 5 seconds and not get canceled */ - usleep(5000000); - has5secsleeped = 1; - assert (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) == 0); - /* thread should cancel here */ - usleep(5000000); - - return NULL; -} - -int main (void) -{ - void * result; - pthread_t t; - - assert (pthread_create (&t, NULL, Thread, NULL) == 0); - assert (pthread_cancel (t) == 0); - assert (pthread_join (t, &result) == 0); - assert (has5secsleeped == 1); - assert (result == PTHREAD_CANCELED); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/cancel9.c b/winsup/testsuite/winsup.api/pthread/cancel9.c deleted file mode 100644 index 1cbf62d2c..000000000 --- a/winsup/testsuite/winsup.api/pthread/cancel9.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * File: cancel9.c - * - * Test Synopsis: Test if waitpid is a cancellation point. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_cancel, pthread_setcancelstate - * pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include -#include - -static pid_t pid; - -static void *Thread(void *punused) -{ - int res; - - pid = fork (); - assert (pid != -1); - switch (pid) - { - case 0: - sleep (10); - break; - default: - assert (waitpid (pid, &res, 0) != -1); - } - - return NULL; -} - -int main (void) -{ - int res; - - void * result; - pthread_t t; - - assert (pthread_create (&t, NULL, Thread, NULL) == 0); - sleep (5); - assert (pthread_cancel (t) == 0); - assert (pthread_join (t, &result) == 0); - assert (result == PTHREAD_CANCELED); - assert (waitpid (pid, &res, 0) != -1); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/cleanup2.c b/winsup/testsuite/winsup.api/pthread/cleanup2.c deleted file mode 100644 index bcbaad3a7..000000000 --- a/winsup/testsuite/winsup.api/pthread/cleanup2.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * File: cleanup2.c - * - * Test Synopsis: Test cleanup handler executes (when thread is not canceled). - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -static int pop_count = 0; - -static void -increment_pop_count(void * arg) -{ - int * c = (int *) arg; - - (*c)++; -} - -void * -mythread(void * arg) -{ - int result = 0; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - pthread_cleanup_push(increment_pop_count, (void *) &pop_count); - - sched_yield(); - - pthread_cleanup_pop(1); - - return (void *) result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()) != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(1000); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - int result = 0; - - assert(pthread_join(t[i], (void **) &result) == 0); - - fail = (result != 0); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: result: %d\n", - i, - threadbag[i].started, - result); - } - failed = (failed || fail); - } - - assert(!failed); - - assert(pop_count == NUMTHREADS); - - /* - * Success. - */ - return 0; -} - diff --git a/winsup/testsuite/winsup.api/pthread/cleanup3.c b/winsup/testsuite/winsup.api/pthread/cleanup3.c deleted file mode 100644 index f8201faa0..000000000 --- a/winsup/testsuite/winsup.api/pthread/cleanup3.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * File: cleanup3.c - * - * Test Synopsis: Test cleanup handler does not execute (when thread is - * not canceled). - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - have working pthread_create, pthread_self, pthread_mutex_lock/unlock - * pthread_testcancel, pthread_cancel, pthread_join - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 10 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ - int count; -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -static int pop_count = 0; - -static void -increment_pop_count(void * arg) -{ - int * c = (int *) arg; - - (*c)++; -} - -void * -mythread(void * arg) -{ - int result = 0; - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - pthread_cleanup_push(increment_pop_count, (void *) &pop_count); - - sched_yield(); - - pop_count--; - - pthread_cleanup_pop(0); - - return (void *) result; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - assert((t[0] = pthread_self()) != NULL); - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - Sleep(1000); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - if (!threadbag[i].started) - { - failed |= !threadbag[i].started; - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. Set "failed" and only print output on failure. - */ - failed = 0; - for (i = 1; i <= NUMTHREADS; i++) - { - int fail = 0; - int result = 0; - - assert(pthread_join(t[i], (void **) &result) == 0); - - fail = (result != 0); - - if (fail) - { - fprintf(stderr, "Thread %d: started %d: result: %d\n", - i, - threadbag[i].started, - result); - } - failed = (failed || fail); - } - - assert(!failed); - - assert(pop_count == -(NUMTHREADS)); - - /* - * Success. - */ - return 0; -} - diff --git a/winsup/testsuite/winsup.api/pthread/condvar1.c b/winsup/testsuite/winsup.api/pthread/condvar1.c deleted file mode 100644 index daa0f420e..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar1.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * File: condvar1.c - * - * Test Synopsis: - * - Test initialisation and destruction of a CV. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Creates and then imediately destroys a CV. Does not - * test the CV. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_init returns 0, and - * - pthread_cond_destroy returns 0. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_init returns non-zero, or - * - pthread_cond_destroy returns non-zero. - * - Process returns non-zero exit status. - */ - -#include "test.h" - -static pthread_cond_t cv = NULL; - -int -main() -{ - assert(cv == NULL); - - assert(pthread_cond_init(&cv, NULL) == 0); - - assert(cv != NULL); - - assert(pthread_cond_destroy(&cv) == 0); - - assert(cv == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar2.c b/winsup/testsuite/winsup.api/pthread/condvar2.c deleted file mode 100644 index 309f5dfdf..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar2.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * File: condvar2.c - * - * Test Synopsis: - * - Test timed wait on a CV. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Because the CV is never signaled, we expect the wait to time out. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait does not return ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -pthread_cond_t cv; -pthread_mutex_t mutex; - -int -main() -{ - struct timespec abstime = { 0, 0 }; - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - int result; - - assert(pthread_cond_init(&cv, NULL) == 0); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(pthread_mutex_lock(&mutex) == 0); - - /* get current system time */ - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == ETIMEDOUT); - - assert(pthread_mutex_unlock(&mutex) == 0); - - result = pthread_cond_destroy(&cv); - assert(result == 0); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar2_1.c b/winsup/testsuite/winsup.api/pthread/condvar2_1.c deleted file mode 100644 index da3416203..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar2_1.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * File: condvar2_1.c - * - * Test Synopsis: - * - Test timeout of multiple waits on a CV with no signal/broadcast. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Because the CV is never signaled, we expect the waits to time out. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait does not return ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -static pthread_cond_t cv; -static pthread_mutex_t mutex; -static struct timespec abstime = { 0, 0 }; - -enum { - NUMTHREADS = 60 -}; - -void * -mythread(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == ETIMEDOUT); - - assert(pthread_mutex_unlock(&mutex) == 0); - - return arg; -} - -int -main() -{ - int i; - pthread_t t[NUMTHREADS + 1]; - int result = 0; - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert(pthread_cond_init(&cv, NULL) == 0); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - /* get current system time */ - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert(pthread_mutex_lock(&mutex) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_create(&t[i], NULL, mythread, (void *) i) == 0); - } - - assert(pthread_mutex_unlock(&mutex) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_join(t[i], (void **) &result) == 0); - assert(result == i); - } - - result = pthread_cond_destroy(&cv); - assert(result == 0); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar3.c b/winsup/testsuite/winsup.api/pthread/condvar3.c deleted file mode 100644 index 249e260aa..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar3.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * File: condvar3.c - * - * Test Synopsis: - * - Test basic function of a CV - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - The primary thread takes the lock before creating any threads. - * The secondary thread blocks on the lock allowing the primary - * thread to enter the cv wait state which releases the lock. - * The secondary thread then takes the lock and signals the waiting - * primary thread. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns 0. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -static pthread_cond_t cv; -static pthread_mutex_t mutex; -static int shared = 0; - -enum { - NUMTHREADS = 2 /* Including the primary thread. */ -}; - -void * -mythread(void * arg) -{ - int result = 0; - - assert(pthread_mutex_lock(&mutex) == 0); - - shared++; - - assert(pthread_mutex_unlock(&mutex) == 0); - - if ((result = pthread_cond_signal(&cv)) != 0) - { - printf("Error = %s\n", error_string[result]); - } - assert(result == 0); - - return (void *) 0; -} - -int -main() -{ - pthread_t t[NUMTHREADS]; - struct timespec abstime = { 0, 0 }; - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert((t[0] = pthread_self()) != NULL); - - assert(pthread_cond_init(&cv, NULL) == 0); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(pthread_mutex_lock(&mutex) == 0); - - /* get current system time */ - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - assert(pthread_create(&t[1], NULL, mythread, (void *) 1) == 0); - - abstime.tv_sec += 5; - - while (! (shared > 0)) - assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == 0); - - assert(shared > 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_cond_destroy(&cv) == 0); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar3_1.c b/winsup/testsuite/winsup.api/pthread/condvar3_1.c deleted file mode 100644 index b08b04889..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar3_1.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * File: condvar3_1.c - * - * Test Synopsis: - * - Test timeout of multiple waits on a CV with some signaled. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Because some CVs are never signaled, we expect their waits to time out. - * Some are signaled, the rest time out. Pthread_cond_destroy() will fail - * unless all are accounted for, either signaled or timedout. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait does not return ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -static pthread_cond_t cv; -static pthread_cond_t cv1; -static pthread_mutex_t mutex; -static struct timespec abstime = { 0, 0 }; -static int timedout = 0; -static int signaled = 0; -static int awoken = 0; -static int waiting = 0; - -enum { - NUMTHREADS = 60 -}; - -void * -mythread(void * arg) -{ - int result; - - assert(pthread_mutex_lock(&mutex) == 0); - - if ( ++waiting == NUMTHREADS) - assert(pthread_cond_signal(&cv1) == 0); - - result = pthread_cond_timedwait(&cv, &mutex, &abstime); - if (result == ETIMEDOUT) - { - timedout++; - } - else - { - awoken++; - } - - assert(pthread_mutex_unlock(&mutex) == 0); - - return arg; -} - -int -main() -{ - int i; - pthread_t t[NUMTHREADS + 1]; - int result = 0; - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert(pthread_cond_init(&cv, NULL) == 0); - assert(pthread_cond_init(&cv1, NULL) == 0); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - /* get current system time */ - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert(pthread_mutex_lock(&mutex) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_create(&t[i], NULL, mythread, (void *) i) == 0); - } - - do { - assert(pthread_cond_wait(&cv1,&mutex) == 0); - } while ( NUMTHREADS != waiting ); - - assert(pthread_mutex_unlock(&mutex) == 0); - - for (i = NUMTHREADS/3; i <= 2*NUMTHREADS/3; i++) - { - assert(pthread_cond_signal(&cv) == 0); - signaled++; - } - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_join(t[i], (void **) &result) == 0); - assert(result == i); - } - - printf("awk = %d\n", awoken); - printf("sig = %d\n", signaled); - printf("tot = %d\n", timedout); - - assert(signaled == awoken); - assert(timedout == NUMTHREADS - signaled); - - result = pthread_cond_destroy(&cv); - assert(result == 0); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar3_2.c b/winsup/testsuite/winsup.api/pthread/condvar3_2.c deleted file mode 100644 index 57e7eb439..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar3_2.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * File: condvar3_2.c - * - * Test Synopsis: - * - Test timeout of multiple waits on a CV with remainder broadcast awoken. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Because some CVs are never signaled, we expect their waits to time out. - * Some time out, the rest are broadcast signaled. Pthread_cond_destroy() will fail - * unless all are accounted for, either signaled or timedout. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait does not return ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -static pthread_cond_t cv; -static pthread_mutex_t mutex; -static struct timespec abstime = { 0, 0 }; -static struct timespec abstime2 = { 0, 0 }; -static int timedout = 0; -static int awoken = 0; - -enum { - NUMTHREADS = 60 -}; - -void * -mythread(void * arg) -{ - int result; - - assert(pthread_mutex_lock(&mutex) == 0); - - abstime2.tv_sec = abstime.tv_sec; - - if ((int) arg % 3 == 0) - { - abstime2.tv_sec += 2; - } - - result = pthread_cond_timedwait(&cv, &mutex, &abstime2); - if (result == ETIMEDOUT) - { - timedout++; - } - else - { - awoken++; - } - - assert(pthread_mutex_unlock(&mutex) == 0); - - return arg; -} - -int -main() -{ - int i; - pthread_t t[NUMTHREADS + 1]; - int result = 0; - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert(pthread_cond_init(&cv, NULL) == 0); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - /* get current system time */ - ftime(&currSysTime); - - abstime.tv_sec = abstime.tv_sec = currSysTime.time + 5; - abstime.tv_nsec = abstime2.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - assert(pthread_mutex_lock(&mutex) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_create(&t[i], NULL, mythread, (void *) i) == 0); - } - - assert(pthread_mutex_unlock(&mutex) == 0); - - for (i = 1; i <= NUMTHREADS; i++) - { - assert(pthread_join(t[i], (void **) &result) == 0); - assert(result == i); - /* - * Approximately 2/3rds of the threads are expected to time out. - * Signal the remainder after some threads have woken up and exited - * and while some are still waking up after timeout. - * Also tests that redundant broadcasts don't return errors. - */ - if (awoken > NUMTHREADS/3) - { - assert(pthread_cond_broadcast(&cv) == 0); - } - } - - assert(awoken == NUMTHREADS - timedout); - - result = pthread_cond_destroy(&cv); - assert(result == 0); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar3_3.c b/winsup/testsuite/winsup.api/pthread/condvar3_3.c deleted file mode 100644 index f6bcca9fa..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar3_3.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * File: condvar3_3.c - * - * Test Synopsis: - * - Test timeouts and lost signals on a CV. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait does not return ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -/* Timur Aydin (taydin@snet.net) */ - -#include "test.h" - -#include - -pthread_cond_t cnd; -pthread_mutex_t mtx; - -int main() -{ - int rc; - - struct timespec abstime = { 0, 0 }; - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert(pthread_cond_init(&cnd, 0) == 0); - assert(pthread_mutex_init(&mtx, 0) == 0); - - /* get current system time */ - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - abstime.tv_sec += 1; - - /* Here pthread_cond_timedwait should time out after one second. */ - - assert(pthread_mutex_lock(&mtx) == 0); - - assert((rc = pthread_cond_timedwait(&cnd, &mtx, &abstime)) == ETIMEDOUT); - - assert(pthread_mutex_unlock(&mtx) == 0); - - /* Here, the condition variable is signaled, but there are no - threads waiting on it. The signal should be lost and - the next pthread_cond_timedwait should time out too. */ - - assert(pthread_mutex_lock(&mtx) == 0); - - assert((rc = pthread_cond_signal(&cnd)) == 0); - - assert(pthread_mutex_unlock(&mtx) == 0); - - assert(pthread_mutex_lock(&mtx) == 0); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - abstime.tv_sec += 1; - - assert((rc = pthread_cond_timedwait(&cnd, &mtx, &abstime)) == ETIMEDOUT); - - assert(pthread_mutex_unlock(&mtx) == 0); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar4.c b/winsup/testsuite/winsup.api/pthread/condvar4.c deleted file mode 100644 index 7a2007a4a..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar4.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * File: condvar4.c - * - * Test Synopsis: - * - Test PTHREAD_COND_INITIALIZER. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Test basic CV function but starting with a static initialised - * CV. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns 0. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -enum { - NUMTHREADS = 2 -}; - -void * -mythread(void * arg) -{ - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - cvthing.shared++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_cond_signal(&cvthing.notbusy) == 0); - - return (void *) 0; -} - -int -main() -{ - pthread_t t[NUMTHREADS]; - struct timespec abstime = { 0, 0 }; - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - cvthing.shared = 0; - - assert((t[0] = pthread_self()) != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - assert(cvthing.lock != PTHREAD_MUTEX_INITIALIZER); - - /* get current system time */ - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == ETIMEDOUT); - - assert(cvthing.notbusy != PTHREAD_COND_INITIALIZER); - - assert(pthread_create(&t[1], NULL, mythread, (void *) 1) == 0); - - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - assert(cvthing.shared > 0); - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar5.c b/winsup/testsuite/winsup.api/pthread/condvar5.c deleted file mode 100644 index b493ab136..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar5.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * File: condvar5.c - * - * Test Synopsis: - * - Test pthread_cond_broadcast. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Test broadcast with one waiting CV. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - pthread_cond_timedwait returns 0. - * - Process returns zero exit status. - * - * Fail Criteria: - * - pthread_cond_timedwait returns ETIMEDOUT. - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -enum { - NUMTHREADS = 2 -}; - -void * -mythread(void * arg) -{ - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - cvthing.shared++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - - return (void *) 0; -} - -int -main() -{ - pthread_t t[NUMTHREADS]; - struct timespec abstime = { 0, 0 }; - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - cvthing.shared = 0; - - assert((t[0] = pthread_self()) != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - assert(cvthing.lock != PTHREAD_MUTEX_INITIALIZER); - - /* get current system time */ - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == ETIMEDOUT); - - assert(cvthing.notbusy != PTHREAD_COND_INITIALIZER); - - assert(pthread_create(&t[1], NULL, mythread, (void *) 1) == 0); - - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - assert(cvthing.shared > 0); - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar6.c b/winsup/testsuite/winsup.api/pthread/condvar6.c deleted file mode 100644 index f011bea13..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar6.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * File: - * - * Test Synopsis: - * - Test pthread_cond_broadcast. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Test broadcast with NUMTHREADS (=5) waiting CVs. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 5 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -static pthread_mutex_t start_flag = PTHREAD_MUTEX_INITIALIZER; - -static struct timespec abstime = { 0, 0 }; - -static int awoken; - -void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Wait for the start gun */ - assert(pthread_mutex_lock(&start_flag) == 0); - assert(pthread_mutex_unlock(&start_flag) == 0); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - assert(cvthing.shared > 0); - - awoken++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - return (void *) 0; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - cvthing.shared = 0; - - assert((t[0] = pthread_self()) != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&start_flag) == 0); - - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert((t[0] = pthread_self()) != NULL); - - awoken = 0; - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - - assert(pthread_mutex_unlock(&start_flag) == 0); - - /* - * Give threads time to start. - */ - Sleep(2000); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - cvthing.shared++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - - /* - * Give threads time to complete. - */ - Sleep(2000); - - /* - * Cleanup the CV. - */ - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. - */ - - assert(awoken == NUMTHREADS); - - /* - * Success. - */ - return 0; -} - - diff --git a/winsup/testsuite/winsup.api/pthread/condvar7.c b/winsup/testsuite/winsup.api/pthread/condvar7.c deleted file mode 100644 index 8e9808f48..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar7.c +++ /dev/null @@ -1,227 +0,0 @@ -/* - * File: condvar7.c - * - * - * Test Synopsis: - * - Test pthread_cond_broadcast with thread cancelation. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Test broadcast with NUMTHREADS (=5) waiting CVs, one is canceled while waiting. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 5 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -static pthread_mutex_t start_flag = PTHREAD_MUTEX_INITIALIZER; - -static struct timespec abstime = { 0, 0 }; - -static int awoken; - -void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Wait for the start gun */ - assert(pthread_mutex_lock(&start_flag) == 0); - assert(pthread_mutex_unlock(&start_flag) == 0); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - -#ifdef _MSC_VER -#pragma inline_depth(0) -#endif - pthread_cleanup_push((void *) pthread_mutex_unlock, (void *) &cvthing.lock); - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - pthread_cleanup_pop(0); -#ifdef _MSC_VER -#pragma inline_depth() -#endif - - assert(cvthing.shared > 0); - - awoken++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - return (void *) 0; -} - -int -main() -{ - int failed = 0; - int i; - pthread_t t[NUMTHREADS + 1]; - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - cvthing.shared = 0; - - assert((t[0] = pthread_self()) != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&start_flag) == 0); - - /* get current system time */ - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 10; - - assert((t[0] = pthread_self()) != NULL); - - awoken = 0; - - for (i = 1; i <= NUMTHREADS; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - - assert(pthread_mutex_unlock(&start_flag) == 0); - - /* - * Give threads time to start. - */ - Sleep(1000); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - cvthing.shared++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - /* - * Cancel one of the threads. - */ - assert(pthread_cancel(t[3]) == 0); - Sleep(500); - - /* - * Signal all remaining waiting threads. - */ - assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - - /* - * Give threads time to complete. - */ - Sleep(2000); - - /* - * Cleanup the CV. - */ - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - assert(!failed); - - /* - * Check any results here. - */ - - assert(awoken == (NUMTHREADS - 1)); - - /* - * Success. - */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar8.c b/winsup/testsuite/winsup.api/pthread/condvar8.c deleted file mode 100644 index 771d91cb5..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar8.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * File: condvar8.c - * - * Test Synopsis: - * - Test multiple pthread_cond_broadcasts. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Make NUMTHREADS threads wait on CV, broadcast signal them, and then repeat. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 5 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -static pthread_mutex_t start_flag = PTHREAD_MUTEX_INITIALIZER; - -static struct timespec abstime = { 0, 0 }; - -static int awoken; - -static void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Wait for the start gun */ - assert(pthread_mutex_lock(&start_flag) == 0); - assert(pthread_mutex_unlock(&start_flag) == 0); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - pthread_cleanup_push((__cleanup_routine_type)pthread_mutex_unlock, - (void *) &cvthing.lock); - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - pthread_cleanup_pop(0); - - assert(cvthing.shared > 0); - - awoken++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - return (void *) 0; -} - -int -main() -{ - int failed = 0; - int i; - int first, last; - pthread_t t[NUMTHREADS + 1]; - - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert((t[0] = pthread_self()) != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 10; - - assert((t[0] = pthread_self()) != NULL); - - awoken = 0; - - for (first = 1, last = NUMTHREADS / 2; - first < NUMTHREADS; - first = last + 1, last = NUMTHREADS) - { - assert(pthread_mutex_lock(&start_flag) == 0); - - for (i = first; i <= last; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - assert(pthread_detach(t[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - cvthing.shared = 0; - - assert(pthread_mutex_unlock(&start_flag) == 0); - - /* - * Give threads time to start. - */ - Sleep(1000); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - cvthing.shared++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - - /* - * Give threads time to complete. - */ - Sleep(1000); - - assert(awoken == (i - 1)); - } - - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - /* - * Cleanup the CV. - */ - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - assert(!failed); - - /* - * Check any results here. - */ - - assert(awoken == NUMTHREADS); - - /* - * Success. - */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/condvar9.c b/winsup/testsuite/winsup.api/pthread/condvar9.c deleted file mode 100644 index 294556266..000000000 --- a/winsup/testsuite/winsup.api/pthread/condvar9.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * File: condvar9.c - * - * - * Test Synopsis: - * - Test multiple pthread_cond_broadcasts with thread cancelation. - * - * Test Method (Validation or Falsification): - * - Validation - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - Make NUMTHREADS threads wait on CV, broadcast signal them, cancel them - * and then repeat. - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" -#include - -/* - * Create NUMTHREADS threads in addition to the Main thread. - */ -enum { - NUMTHREADS = 9 -}; - -typedef struct bag_t_ bag_t; -struct bag_t_ { - int threadnum; - int started; - /* Add more per-thread state variables here */ -}; - -static bag_t threadbag[NUMTHREADS + 1]; - -typedef struct cvthing_t_ cvthing_t; - -struct cvthing_t_ { - pthread_cond_t notbusy; - pthread_mutex_t lock; - int shared; -}; - -static cvthing_t cvthing = { - PTHREAD_COND_INITIALIZER, - PTHREAD_MUTEX_INITIALIZER, - 0 -}; - -static pthread_mutex_t start_flag = PTHREAD_MUTEX_INITIALIZER; - -static struct timespec abstime = { 0, 0 }; - -static int awoken; -static int not_canceled; - -static void * -mythread(void * arg) -{ - bag_t * bag = (bag_t *) arg; - - assert(bag == &threadbag[bag->threadnum]); - assert(bag->started == 0); - bag->started = 1; - - /* Wait for the start gun */ - assert(pthread_mutex_lock(&start_flag) == 0); - assert(pthread_mutex_unlock(&start_flag) == 0); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - /* - * pthread_cond_timedwait is a cancelation point and we - * going to cancel one deliberately. - */ -#ifdef _MSC_VER -#pragma inline_depth(0) -#endif - pthread_cleanup_push((void *) pthread_mutex_unlock, (void *) &cvthing.lock); - - while (! (cvthing.shared > 0)) - assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0); - - assert(cvthing.shared > 0); - - awoken++; - - pthread_testcancel(); - - pthread_cleanup_pop(0); -#ifdef _MSC_VER -#pragma inline_depth() -#endif - - not_canceled++; - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - return (void *) 0; -} - -int -main() -{ - int failed = 0; - int i; - int first, last; - pthread_t t[NUMTHREADS + 1]; - struct timeb currSysTime; - const DWORD NANOSEC_PER_MILLISEC = 1000000; - - assert((t[0] = pthread_self()) != NULL); - - assert(cvthing.notbusy == PTHREAD_COND_INITIALIZER); - - assert(cvthing.lock == PTHREAD_MUTEX_INITIALIZER); - - /* get current system time */ - ftime(&currSysTime); - - abstime.tv_sec = currSysTime.time; - abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - - abstime.tv_sec += 5; - - assert((t[0] = pthread_self()) != NULL); - - awoken = 0; - not_canceled = 0; - - for (first = 1, last = NUMTHREADS / 2; - first < NUMTHREADS; - first = last + 1, last = NUMTHREADS) - { - assert(pthread_mutex_lock(&start_flag) == 0); - - for (i = first; i <= last; i++) - { - threadbag[i].started = 0; - threadbag[i].threadnum = i; - assert(pthread_create(&t[i], NULL, mythread, (void *) &threadbag[i]) == 0); - assert(pthread_detach(t[i]) == 0); - } - - /* - * Code to control or munipulate child threads should probably go here. - */ - cvthing.shared = 0; - - assert(pthread_mutex_unlock(&start_flag) == 0); - - /* - * Give threads time to start. - */ - Sleep(1000); - - assert(pthread_mutex_lock(&cvthing.lock) == 0); - - cvthing.shared++; - - assert(pthread_cond_broadcast(&cvthing.notbusy) == 0); - for (i = first; i <= last; i++) - assert(pthread_cancel(t[i]) == 0); - - assert(pthread_mutex_unlock(&cvthing.lock) == 0); - - /* - * Give threads time to complete. - */ - Sleep(1000); - } - - - /* - * Standard check that all threads started. - */ - for (i = 1; i <= NUMTHREADS; i++) - { - failed = !threadbag[i].started; - - if (failed) - { - fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started); - } - } - - /* - * Cleanup the CV. - */ - - assert(pthread_mutex_destroy(&cvthing.lock) == 0); - - assert(cvthing.lock == NULL); - - assert(pthread_cond_destroy(&cvthing.notbusy) == 0); - - assert(cvthing.notbusy == NULL); - - assert(!failed); - - /* - * Check any results here. - */ - - assert(awoken == NUMTHREADS); - assert(not_canceled == 0); - - /* - * Success. - */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/count1.c b/winsup/testsuite/winsup.api/pthread/count1.c deleted file mode 100644 index ae30ed0a2..000000000 --- a/winsup/testsuite/winsup.api/pthread/count1.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * count1.c - * - * Description: - * Test some basic assertions about the number of threads at runtime. - */ - -#include "test.h" - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) -#define NUMTHREADS (60) -#else -#define NUMTHREADS (59) -#endif - -static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_t threads[NUMTHREADS]; -static unsigned numThreads = 0; - -void * -myfunc(void *arg) -{ - pthread_mutex_lock(&lock); - numThreads++; - pthread_mutex_unlock(&lock); - - Sleep(1000); - return 0; -} -int -main() -{ - int i; - int maxThreads = sizeof(threads) / sizeof(pthread_t); - - /* - * Spawn NUMTHREADS threads. Each thread should increment the - * numThreads variable, sleep for one second. - */ - for (i = 0; i < maxThreads; i++) - { - assert(pthread_create(&threads[i], NULL, myfunc, 0) == 0); - } - - /* - * Wait for all the threads to exit. - */ - for (i = 0; i < maxThreads; i++) - { - assert(pthread_join(threads[i], NULL) == 0); - } - - /* - * Check the number of threads created. - */ - assert((int) numThreads == maxThreads); - - /* - * Success. - */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/create1.c b/winsup/testsuite/winsup.api/pthread/create1.c deleted file mode 100644 index 192e52d9d..000000000 --- a/winsup/testsuite/winsup.api/pthread/create1.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * create1.c - * - * Description: - * Create a thread and check that it ran. - * - * Depends on API functions: None. - */ - -#include "test.h" - -static int washere = 0; - -void * func(void * arg) -{ - washere = 1; - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - /* A dirty hack, but we cannot rely on pthread_join in this - primitive test. */ - Sleep(2000); - - assert(washere == 1); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/create2.c b/winsup/testsuite/winsup.api/pthread/create2.c deleted file mode 100644 index 40e637b9d..000000000 --- a/winsup/testsuite/winsup.api/pthread/create2.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * File: create2.c - * - * Test Synopsis: - * - Test that threads have a Win32 handle when started. - * - * Test Method (Validation or Falsification): - * - Statistical, not absolute (depends on sample size). - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -const int NUMTHREADS = 10000; - -static int washere = 0; - -void * func(void * arg) -{ - washere = 1; - return (void *) 0; -} - -int -main() -{ - pthread_t t; - pthread_attr_t attr; - void * result = NULL; - int i; - - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - - for (i = 0; i < NUMTHREADS; i++) - { - washere = 0; - assert(pthread_create(&t, &attr, func, NULL) == 0); - pthread_join(t, &result); - assert(washere == 1); - } - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/equal1.c b/winsup/testsuite/winsup.api/pthread/equal1.c deleted file mode 100644 index 617a95664..000000000 --- a/winsup/testsuite/winsup.api/pthread/equal1.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Test for pthread_equal. - * - * Depends on functions: pthread_create(). - */ - -#include "test.h" - -void * func(void * arg) -{ - Sleep(2000); - return 0; -} - -int -main() -{ - pthread_t t1, t2; - - assert(pthread_create(&t1, NULL, func, (void *) 1) == 0); - - assert(pthread_create(&t2, NULL, func, (void *) 2) == 0); - - assert(pthread_equal(t1, t2) == 0); - - assert(pthread_equal(t1,t1) != 0); - - /* This is a hack. We don't want to rely on pthread_join - yet if we can help it. */ - Sleep(4000); - - /* Success. */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/exit1.c b/winsup/testsuite/winsup.api/pthread/exit1.c deleted file mode 100644 index 06b7692de..000000000 --- a/winsup/testsuite/winsup.api/pthread/exit1.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Test for pthread_exit(). - * - * Depends on API functions: None. - */ - -#include "test.h" - -int -main(int argc, char * argv[]) -{ - /* A simple test first. */ - pthread_exit((void *) 0); - - /* Not reached */ - assert(0); - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/exit2.c b/winsup/testsuite/winsup.api/pthread/exit2.c deleted file mode 100644 index 684305b40..000000000 --- a/winsup/testsuite/winsup.api/pthread/exit2.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Test for pthread_exit(). - * - * Depends on API functions: - * pthread_create() - * pthread_exit() - */ - -#include "test.h" - -void * -func(void * arg) -{ - pthread_exit(arg); - - /* Never reached. */ - assert(0); -} - -int -main(int argc, char * argv[]) -{ - pthread_t t; - - assert(pthread_create(&t, NULL, func, (void *) NULL) == 0); - - Sleep(1000); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/exit3.c b/winsup/testsuite/winsup.api/pthread/exit3.c deleted file mode 100644 index 0b6ec31c5..000000000 --- a/winsup/testsuite/winsup.api/pthread/exit3.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Test for pthread_exit(). - * - * Depends on API functions: pthread_create(). - */ - -#include "test.h" - -void * -func(void * arg) -{ - pthread_exit(arg); - - /* Never reached. */ - assert(0); -} - -int -main(int argc, char * argv[]) -{ - pthread_t id[4]; - int i; - - /* Create a few threads and then exit. */ - for (i = 0; i < 4; i++) - { - assert(pthread_create(&id[i], NULL, func, (void *) i) == 0); - } - - Sleep(1000); - - /* Success. */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/inherit1.c b/winsup/testsuite/winsup.api/pthread/inherit1.c deleted file mode 100644 index a909eb763..000000000 --- a/winsup/testsuite/winsup.api/pthread/inherit1.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * File: inherit1.c - * - * Test Synopsis: - * - Test thread priority inheritance. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -void * func(void * arg) -{ - int policy; - struct sched_param param; - - assert(pthread_getschedparam(pthread_self(), &policy, ¶m) == 0); - return (void *) param.sched_priority; -} - -int -main() -{ - pthread_t t; - pthread_t mainThread = pthread_self(); - pthread_attr_t attr; - void * result = NULL; - struct sched_param param; - struct sched_param mainParam; - int maxPrio; - int minPrio; - int prio; - int policy; - int inheritsched = -1; - - assert((maxPrio = sched_get_priority_max(SCHED_OTHER)) != -1); - assert((minPrio = sched_get_priority_min(SCHED_OTHER)) != -1); - - assert(pthread_attr_init(&attr) == 0); - assert(pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED) == 0); - assert(pthread_attr_getinheritsched(&attr, &inheritsched) == 0); - assert(inheritsched == PTHREAD_INHERIT_SCHED); - - for (prio = minPrio; prio < maxPrio; prio++) - { - mainParam.sched_priority = prio; - - /* Change the main thread priority */ - assert(pthread_setschedparam(mainThread, SCHED_OTHER, &mainParam) == 0); - assert(pthread_getschedparam(mainThread, &policy, &mainParam) == 0); - assert(policy == SCHED_OTHER); - assert(mainParam.sched_priority == prio); - - for (param.sched_priority = prio; - param.sched_priority <= maxPrio; - param.sched_priority++) - { - /* The new thread create should ignore this new priority */ - assert(pthread_attr_setschedparam(&attr, ¶m) == 0); - assert(pthread_create(&t, &attr, func, NULL) == 0); - pthread_join(t, &result); - assert((int) result == mainParam.sched_priority); - } - } - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/join0.c b/winsup/testsuite/winsup.api/pthread/join0.c deleted file mode 100644 index 54b0bee6b..000000000 --- a/winsup/testsuite/winsup.api/pthread/join0.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Test for pthread_join(). - * - * Depends on API functions: pthread_create(), pthread_exit(). - */ - -#include "test.h" - -void * -func(void * arg) -{ - Sleep(2000); - - pthread_exit(arg); - - /* Never reached. */ - exit(1); -} - -int -main(int argc, char * argv[]) -{ - pthread_t id; - int result; - - /* Create a single thread and wait for it to exit. */ - assert(pthread_create(&id, NULL, func, (void *) 123) == 0); - - assert(pthread_join(id, (void **) &result) == 0); - -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - assert(result == 123); -#else -# warning pthread_join not fully supported in this configuration. - assert(result == 0); -#endif - - /* Success. */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/join1.c b/winsup/testsuite/winsup.api/pthread/join1.c deleted file mode 100644 index d74e0c484..000000000 --- a/winsup/testsuite/winsup.api/pthread/join1.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Test for pthread_join(). - * - * Depends on API functions: pthread_create(), pthread_join(), pthread_exit(). - */ - -#include "test.h" - -void * -func(void * arg) -{ - int i = (int) arg; - - Sleep(i * 500); - - pthread_exit(arg); - - /* Never reached. */ - exit(1); -} - -int -main(int argc, char * argv[]) -{ - pthread_t id[4]; - int i; - int result; - - /* Create a few threads and then exit. */ - for (i = 0; i < 4; i++) - { - assert(pthread_create(&id[i], NULL, func, (void *) i) == 0); - } - - /* Some threads will finish before they are joined, some after. */ - Sleep(1000); - - for (i = 0; i < 4; i++) - { - assert(pthread_join(id[i], (void **) &result) == 0); -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - assert(result == i); -#else -# warning pthread_join not fully supported in this configuration. - assert(result == 0); -#endif - } - - /* Success. */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/join2.c b/winsup/testsuite/winsup.api/pthread/join2.c deleted file mode 100644 index cdc8ca2d9..000000000 --- a/winsup/testsuite/winsup.api/pthread/join2.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Test for pthread_join() returning return value from threads. - * - * Depends on API functions: pthread_create(). - */ - -#include "test.h" - -void * -func(void * arg) -{ - Sleep(1000); - return arg; -} - -int -main(int argc, char * argv[]) -{ - pthread_t id[4]; - int i; - int result; - - /* Create a few threads and then exit. */ - for (i = 0; i < 4; i++) - { - assert(pthread_create(&id[i], NULL, func, (void *) i) == 0); - } - - for (i = 0; i < 4; i++) - { - assert(pthread_join(id[i], (void **) &result) == 0); -#if ! defined (__MINGW32__) || defined (__MSVCRT__) - /* CRTDLL _beginthread doesn't support return value, so - the assertion is guaranteed to fail. */ - assert(result == i); -#endif - } - - /* Success. */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mainthreadexits.c b/winsup/testsuite/winsup.api/pthread/mainthreadexits.c deleted file mode 100644 index b3a3653b8..000000000 --- a/winsup/testsuite/winsup.api/pthread/mainthreadexits.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include -#include - -static void * Thread (void *); - -static pthread_t main_thread; -static pthread_t secondThread; -static int result = 2; - -int main(void) -{ - main_thread = pthread_self (); - - if (pthread_create (&secondThread, NULL, Thread, NULL)) - exit (1); - sleep (5); - pthread_exit (&result); - /* If pthread_exit doesm't (which would be a bug) then we do */ - return 1; -} - -static void * Thread (void *not_used) -{ - void *myresult; - /* We should be able to join this */ - if (pthread_join (main_thread, &myresult)) - exit (1); - - if (*(int *)myresult != 2) - exit (1); - - exit (0); -} -/* -This valid code doesn't work at all. The mainthread object in MTinterface -is not properly initialized, the cancel_event is NULL and the win32_obj_id -is NULL because myself->hProcess is NULL when MTinterface is initialized -(and i don't think that a process handle can be used as thread handle). -Even if the handles would be valid the pthread_join call would try to -delete a thread object that is created static which would result in a -corrupted heap. - -Concept test Contributed by Thomas Pfaff -Scriptable test by Robert Collins - -*/ diff --git a/winsup/testsuite/winsup.api/pthread/mutex1.c b/winsup/testsuite/winsup.api/pthread/mutex1.c deleted file mode 100644 index b7f6b6f15..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex1.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * mutex1.c - * - * Create a simple mutex object, lock it, and then unlock it again. - * This is the simplest test of the pthread mutex family that we can do. - * - * Depends on API functions: - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - * pthread_mutex_destroy() - */ - -#include "test.h" - -pthread_mutex_t mutex = NULL; - -int -main() -{ - assert(mutex == NULL); - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(mutex != NULL); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex1d.c b/winsup/testsuite/winsup.api/pthread/mutex1d.c deleted file mode 100644 index 354b106d1..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex1d.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * mutex1d.c - * - * As for mutex1.c but with type set to PTHREAD_MUTEX_DEFAULT. - * - * Create a simple mutex object, lock it, unlock it, then destroy it. - * This is the simplest test of the pthread mutex family that we can do. - * - * Depends on API functions: - * pthread_mutexattr_settype() - * pthread_mutex_init() - * pthread_mutex_destroy() - */ - -#include "test.h" - -pthread_mutex_t mutex = NULL; -pthread_mutexattr_t mxAttr; - -int -main() -{ - assert(pthread_mutexattr_init(&mxAttr) == 0); - - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_DEFAULT) == 0); - - assert(mutex == NULL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(mutex != NULL); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex1e.c b/winsup/testsuite/winsup.api/pthread/mutex1e.c deleted file mode 100644 index 2feb16c08..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex1e.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * mutex1e.c - * - * As for mutex1.c but with type set to PTHREAD_MUTEX_ERRORCHECK. - * - * Create a simple mutex object, lock it, unlock it, then destroy it. - * This is the simplest test of the pthread mutex family that we can do. - * - * Depends on API functions: - * pthread_mutexattr_settype() - * pthread_mutex_init() - * pthread_mutex_destroy() - */ - -#include "test.h" - -pthread_mutex_t mutex = NULL; -pthread_mutexattr_t mxAttr; - -int -main() -{ - assert(pthread_mutexattr_init(&mxAttr) == 0); - - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_ERRORCHECK) == 0); - - assert(mutex == NULL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(mutex != NULL); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex1n.c b/winsup/testsuite/winsup.api/pthread/mutex1n.c deleted file mode 100644 index 9af3d5f5c..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex1n.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * mutex1n.c - * - * As for mutex1.c but with type set to PTHREAD_MUTEX_NORMAL. - * - * Create a simple mutex object, lock it, unlock it, then destroy it. - * This is the simplest test of the pthread mutex family that we can do. - * - * Depends on API functions: - * pthread_mutexattr_settype() - * pthread_mutex_init() - * pthread_mutex_destroy() - */ - -#include "test.h" - -pthread_mutex_t mutex = NULL; -pthread_mutexattr_t mxAttr; - -int -main() -{ - assert(pthread_mutexattr_init(&mxAttr) == 0); - - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_NORMAL) == 0); - - assert(mutex == NULL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(mutex != NULL); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex1r.c b/winsup/testsuite/winsup.api/pthread/mutex1r.c deleted file mode 100644 index b5131bb0e..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex1r.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * mutex1r.c - * - * As for mutex1.c but with type set to PTHREAD_MUTEX_RECURSIVE. - * - * Create a simple mutex object, lock it, unlock it, then destroy it. - * This is the simplest test of the pthread mutex family that we can do. - * - * Depends on API functions: - * pthread_mutexattr_settype() - * pthread_mutex_init() - * pthread_mutex_destroy() - */ - -#include "test.h" - -pthread_mutex_t mutex = NULL; -pthread_mutexattr_t mxAttr; - -int -main() -{ - assert(pthread_mutexattr_init(&mxAttr) == 0); - - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_RECURSIVE) == 0); - - assert(mutex == NULL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(mutex != NULL); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex2.c b/winsup/testsuite/winsup.api/pthread/mutex2.c deleted file mode 100644 index 731c47fab..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * mutex2.c - * - * Declare a static mutex object, lock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - -int -main() -{ - assert(mutex == PTHREAD_MUTEX_INITIALIZER); - - assert(pthread_mutex_lock(&mutex) == 0); - - assert(mutex != PTHREAD_MUTEX_INITIALIZER); - - assert(mutex != NULL); - - assert(pthread_mutex_unlock(&mutex) == 0); - - assert(pthread_mutex_destroy(&mutex) == 0); - - assert(mutex == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex3.c b/winsup/testsuite/winsup.api/pthread/mutex3.c deleted file mode 100644 index 07e75b187..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex3.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * mutex3.c - * - * Declare a static mutex object, lock it, trylock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_mutex_trylock(&mutex1) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_mutex_lock(&mutex1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - assert(pthread_join(t, NULL) == 0); - - assert(pthread_mutex_unlock(&mutex1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex4.c b/winsup/testsuite/winsup.api/pthread/mutex4.c deleted file mode 100644 index 2cc858015..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex4.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * mutex4.c - * - * Thread A locks mutex - thread B tries to unlock. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int wasHere = 0; - -static pthread_mutex_t mutex1; - -void * unlocker(void * arg) -{ - int expectedResult = (int) arg; - - wasHere++; - assert(pthread_mutex_unlock(&mutex1) == expectedResult); - wasHere++; - return NULL; -} - -int -main() -{ - pthread_t t; - pthread_mutexattr_t ma; - - assert(pthread_mutexattr_init(&ma) == 0); - - wasHere = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_DEFAULT) == 0); - assert(pthread_mutex_init(&mutex1, &ma) == 0); - assert(pthread_mutex_lock(&mutex1) == 0); - assert(pthread_create(&t, NULL, unlocker, (void *) EPERM) == 0); - assert(pthread_join(t, NULL) == 0); - assert(pthread_mutex_unlock(&mutex1) == 0); - assert(pthread_mutex_destroy(&mutex1) == 0); - assert(wasHere == 2); - - wasHere = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutex_init(&mutex1, &ma) == 0); - assert(pthread_mutex_lock(&mutex1) == 0); - assert(pthread_create(&t, NULL, unlocker, (void *) EPERM) == 0); - assert(pthread_join(t, NULL) == 0); - assert(pthread_mutex_unlock(&mutex1) == 0); - assert(pthread_mutex_destroy(&mutex1) == 0); - assert(wasHere == 2); - - wasHere = 0; - assert(pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE) == 0); - assert(pthread_mutex_init(&mutex1, &ma) == 0); - assert(pthread_mutex_lock(&mutex1) == 0); - assert(pthread_create(&t, NULL, unlocker, (void *) EPERM) == 0); - assert(pthread_join(t, NULL) == 0); - assert(pthread_mutex_unlock(&mutex1) == 0); - assert(pthread_mutex_destroy(&mutex1) == 0); - assert(wasHere == 2); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex5.c b/winsup/testsuite/winsup.api/pthread/mutex5.c deleted file mode 100644 index 5cb1478b8..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex5.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * mutex5.c - * - * Confirm the equality/inequality of the various mutex types, - * and the default not-set value. - */ - -#include "test.h" - -static pthread_mutexattr_t mxAttr; - -int -main() -{ - int mxType = -1; - int success = 0; /* Use to quell GNU compiler warnings. */ - - assert(success = PTHREAD_MUTEX_DEFAULT == PTHREAD_MUTEX_ERRORCHECK); - assert(success = PTHREAD_MUTEX_DEFAULT != PTHREAD_MUTEX_RECURSIVE); - assert(success = PTHREAD_MUTEX_RECURSIVE != PTHREAD_MUTEX_ERRORCHECK); - - if (success == success) - { - assert(pthread_mutexattr_init(&mxAttr) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_ERRORCHECK); - } - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex6d.c b/winsup/testsuite/winsup.api/pthread/mutex6d.c deleted file mode 100644 index bcbcd9767..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex6d.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * mutex6d.c - * - * Tests PTHREAD_MUTEX_DEFAULT mutex type. - * The thread should behave the same way than an errorchecking mutex. - * - * Depends on API functions: - * pthread_create() - * pthread_mutexattr_init() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex) == EDEADLK); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == EPERM); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - int result = 0; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_DEFAULT) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_DEFAULT); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, (void **) &result) == 0); - assert(result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - assert(pthread_mutexattr_destroy(&mxAttr) == 0); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex6e.c b/winsup/testsuite/winsup.api/pthread/mutex6e.c deleted file mode 100644 index e22550f7a..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex6e.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * mutex6e.c - * - * Tests PTHREAD_MUTEX_ERRORCHECK mutex type. - * Thread locks mutex twice (recursive lock). - * This should fail with an EDEADLK error. - * The second unlock attempt should fail with an EPERM error. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex) == EDEADLK); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == EPERM); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - int result = 0; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_ERRORCHECK); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, (void **) &result) == 0); - assert(result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - assert(pthread_mutexattr_destroy(&mxAttr) == 0); - - exit(0); - - /* Never reached */ - return 0; -} - diff --git a/winsup/testsuite/winsup.api/pthread/mutex6n.c b/winsup/testsuite/winsup.api/pthread/mutex6n.c deleted file mode 100644 index 38cbba034..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex6n.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * mutex6n.c - * - * Tests PTHREAD_MUTEX_NORMAL mutex type. - * Thread locks mutex twice (recursive lock). - * The thread should deadlock. - * - * Depends on API functions: - * pthread_create() - * pthread_mutexattr_init() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - - /* Should wait here (deadlocked) */ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_NORMAL) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_NORMAL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(1000); - - assert(lockCount == 1); - - /* - * Should succeed even though we don't own the lock - * because FAST mutexes don't check ownership. - */ - assert(pthread_mutex_unlock(&mutex) == 0); - - Sleep (1000); - - assert(lockCount == 2); - - exit(0); - - /* Never reached */ - return 0; -} - diff --git a/winsup/testsuite/winsup.api/pthread/mutex6r.c b/winsup/testsuite/winsup.api/pthread/mutex6r.c deleted file mode 100644 index 586cc841b..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex6r.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * mutex6r.c - * - * Tests PTHREAD_MUTEX_RECURSIVE mutex type. - * Thread locks mutex twice (recursive lock). - * Both locks and unlocks should succeed. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - int result = 0; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_RECURSIVE) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_RECURSIVE); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, (void **) &result) == 0); - assert(result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - assert(pthread_mutexattr_destroy(&mxAttr) == 0); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex7.c b/winsup/testsuite/winsup.api/pthread/mutex7.c deleted file mode 100644 index d2c9f8bee..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex7.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * mutex7.c - * - * Test the default (type not set) mutex type. - * Should be the same as PTHREAD_MUTEX_ERRORCHECK. - * Thread locks then trylocks mutex (attempted recursive lock). - * The thread should lock first time and EBUSY second time. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_trylock(&mutex) == EBUSY); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == EPERM); - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(1000); - - assert(lockCount == 2); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex7d.c b/winsup/testsuite/winsup.api/pthread/mutex7d.c deleted file mode 100644 index 906d0f043..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex7d.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * mutex7d.c - * - * Test the default (type not set) mutex type. - * Should be the same as PTHREAD_MUTEX_ERRORCHECK. - * Thread locks then trylocks mutex (attempted recursive lock). - * The thread should lock first time and EBUSY second time. - * - * Depends on API functions: - * pthread_mutex_lock() - * pthread_mutex_trylock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_trylock(&mutex) == EBUSY); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == EPERM); - - return 0; -} - -int -main() -{ - int result = 0; - pthread_t t; - - assert(pthread_mutex_init(&mutex, NULL) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, (void **) &result) == 0); - - assert(lockCount == 2); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/mutex7e.c b/winsup/testsuite/winsup.api/pthread/mutex7e.c deleted file mode 100644 index 05722512d..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex7e.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * mutex7e.c - * - * Tests PTHREAD_MUTEX_ERRORCHECK mutex type. - * Thread locks and then trylocks mutex (attempted recursive lock). - * Trylock should fail with an EBUSY error. - * The second unlock attempt should fail with an EPERM error. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_trylock(&mutex) == EBUSY); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == EPERM); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - int result = 0; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_ERRORCHECK) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_ERRORCHECK); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, (void **) &result) == 0); - assert(result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - assert(pthread_mutexattr_destroy(&mxAttr) == 0); - - exit(0); - - /* Never reached */ - return 0; -} - diff --git a/winsup/testsuite/winsup.api/pthread/mutex7n.c b/winsup/testsuite/winsup.api/pthread/mutex7n.c deleted file mode 100644 index e9a36fec0..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex7n.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * mutex7n.c - * - * Tests PTHREAD_MUTEX_NORMAL mutex type. - * Thread locks then trylocks mutex (attempted recursive lock). - * The thread should lock first time and EBUSY second time. - * - * Depends on API functions: - * pthread_create() - * pthread_mutexattr_init() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_trylock(&mutex) == EBUSY); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == EPERM); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_NORMAL) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_NORMAL); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - Sleep(1000); - - assert(lockCount == 2); - - exit(0); - - /* Never reached */ - return 0; -} - diff --git a/winsup/testsuite/winsup.api/pthread/mutex7r.c b/winsup/testsuite/winsup.api/pthread/mutex7r.c deleted file mode 100644 index 6f9ed744b..000000000 --- a/winsup/testsuite/winsup.api/pthread/mutex7r.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * mutex7r.c - * - * Tests PTHREAD_MUTEX_RECURSIVE mutex type. - * Thread locks mutex then trylocks mutex (recursive lock twice). - * Both locks and unlocks should succeed. - * - * Depends on API functions: - * pthread_create() - * pthread_join() - * pthread_mutexattr_init() - * pthread_mutexattr_destroy() - * pthread_mutexattr_settype() - * pthread_mutexattr_gettype() - * pthread_mutex_init() - * pthread_mutex_destroy() - * pthread_mutex_lock() - * pthread_mutex_unlock() - */ - -#include "test.h" - -static int lockCount = 0; - -static pthread_mutex_t mutex; -static pthread_mutexattr_t mxAttr; - -void * locker(void * arg) -{ - assert(pthread_mutex_lock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_trylock(&mutex) == 0); - lockCount++; - assert(pthread_mutex_unlock(&mutex) == 0); - assert(pthread_mutex_unlock(&mutex) == 0); - - return (void *) 555; -} - -int -main() -{ - pthread_t t; - int result = 0; - int mxType = -1; - - assert(pthread_mutexattr_init(&mxAttr) == 0); - assert(pthread_mutexattr_settype(&mxAttr, PTHREAD_MUTEX_RECURSIVE) == 0); - assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); - assert(mxType == PTHREAD_MUTEX_RECURSIVE); - - assert(pthread_mutex_init(&mutex, &mxAttr) == 0); - - assert(pthread_create(&t, NULL, locker, NULL) == 0); - - assert(pthread_join(t, (void **) &result) == 0); - assert(result == 555); - - assert(lockCount == 2); - - assert(pthread_mutex_destroy(&mutex) == 0); - assert(pthread_mutexattr_destroy(&mxAttr) == 0); - - exit(0); - - /* Never reached */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/once1.c b/winsup/testsuite/winsup.api/pthread/once1.c deleted file mode 100644 index 91dc03832..000000000 --- a/winsup/testsuite/winsup.api/pthread/once1.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * once1.c - * - * Create a static pthread_once and test that it calls myfunc once. - * - * Depends on API functions: - * pthread_once() - * pthread_create() - */ - -#include "test.h" - -pthread_once_t once = PTHREAD_ONCE_INIT; - -static int washere = 0; - -void -myfunc(void) -{ - washere++; -} - -void * -mythread(void * arg) -{ - assert(pthread_once(&once, myfunc) == 0); - - return 0; -} - -int -main() -{ - pthread_t t1, t2; - - assert(pthread_create(&t1, NULL, mythread, NULL) == 0); - - assert(pthread_create(&t2, NULL, mythread, NULL) == 0); - - Sleep(2000); - - assert(washere == 1); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/priority1.c b/winsup/testsuite/winsup.api/pthread/priority1.c deleted file mode 100644 index a31102895..000000000 --- a/winsup/testsuite/winsup.api/pthread/priority1.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * File: priority1.c - * - * Test Synopsis: - * - Test thread priority explicit setting using thread attribute. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -void * func(void * arg) -{ - int policy; - struct sched_param param; - - assert(pthread_getschedparam(pthread_self(), &policy, ¶m) == 0); - assert(policy == SCHED_OTHER); - return (void *) param.sched_priority; -} - -int -main() -{ - pthread_t t; - pthread_attr_t attr; - void * result = NULL; - struct sched_param param; - int maxPrio = sched_get_priority_max(SCHED_OTHER); - int minPrio = sched_get_priority_min(SCHED_OTHER); - - assert(pthread_attr_init(&attr) == 0); - assert(pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED) == 0); - - for (param.sched_priority = minPrio; - param.sched_priority <= maxPrio; - param.sched_priority++) - { - assert(pthread_attr_setschedparam(&attr, ¶m) == 0); - assert(pthread_create(&t, &attr, func, NULL) == 0); - pthread_join(t, &result); - assert((int) result == param.sched_priority); - } - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/priority2.c b/winsup/testsuite/winsup.api/pthread/priority2.c deleted file mode 100644 index 4dcf3859f..000000000 --- a/winsup/testsuite/winsup.api/pthread/priority2.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * File: priority2.c - * - * Test Synopsis: - * - Test thread priority setting after creation. - * - * Test Method (Validation or Falsification): - * - - * - * Requirements Tested: - * - - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Description: - * - - * - * Environment: - * - - * - * Input: - * - None. - * - * Output: - * - File name, Line number, and failed expression on failure. - * - No output on success. - * - * Assumptions: - * - - * - * Pass Criteria: - * - Process returns zero exit status. - * - * Fail Criteria: - * - Process returns non-zero exit status. - */ - -#include "test.h" - -pthread_mutex_t startMx = PTHREAD_MUTEX_INITIALIZER; - -void * func(void * arg) -{ - int policy; - struct sched_param param; - - assert(pthread_mutex_lock(&startMx) == 0); - assert(pthread_getschedparam(pthread_self(), &policy, ¶m) == 0); - assert(pthread_mutex_unlock(&startMx) == 0); - assert(policy == SCHED_OTHER); - return (void *) param.sched_priority; -} - -int -main() -{ - pthread_t t; - void * result = NULL; - struct sched_param param; - int maxPrio = sched_get_priority_max(SCHED_OTHER); - int minPrio = sched_get_priority_min(SCHED_OTHER); - - for (param.sched_priority = minPrio; - param.sched_priority <= maxPrio; - param.sched_priority++) - { - assert(pthread_mutex_lock(&startMx) == 0); - assert(pthread_create(&t, NULL, func, NULL) == 0); - assert(pthread_setschedparam(t, SCHED_OTHER, ¶m) == 0); - assert(pthread_mutex_unlock(&startMx) == 0); - pthread_join(t, &result); - assert((int) result == param.sched_priority); - } - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/rwlock1.c b/winsup/testsuite/winsup.api/pthread/rwlock1.c deleted file mode 100644 index 25e29f6ac..000000000 --- a/winsup/testsuite/winsup.api/pthread/rwlock1.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * rwlock1.c - * - * Create a simple rwlock object and then destroy it. - * - * Depends on API functions: - * pthread_rwlock_init() - * pthread_rwlock_destroy() - */ - -#include "test.h" - -pthread_rwlock_t rwlock = NULL; - -int -main() -{ - assert(rwlock == NULL); - - assert(pthread_rwlock_init(&rwlock, NULL) == 0); - - assert(rwlock != NULL); - - assert(pthread_rwlock_destroy(&rwlock) == 0); - - assert(rwlock == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/rwlock2.c b/winsup/testsuite/winsup.api/pthread/rwlock2.c deleted file mode 100644 index cfb32282c..000000000 --- a/winsup/testsuite/winsup.api/pthread/rwlock2.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * rwlock2.c - * - * Declare a static rwlock object, lock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_rwlock_rdlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" - -pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER; - -int -main() -{ - assert(rwlock == PTHREAD_RWLOCK_INITIALIZER); - - assert(pthread_rwlock_rdlock(&rwlock) == 0); - - assert(rwlock != PTHREAD_RWLOCK_INITIALIZER); - - assert(rwlock != NULL); - - assert(pthread_rwlock_unlock(&rwlock) == 0); - - assert(pthread_rwlock_destroy(&rwlock) == 0); - - assert(rwlock == NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/rwlock3.c b/winsup/testsuite/winsup.api/pthread/rwlock3.c deleted file mode 100644 index 0703c1a2d..000000000 --- a/winsup/testsuite/winsup.api/pthread/rwlock3.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * rwlock3.c - * - * - * Declare a static rwlock object, wrlock it, trywrlock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_rwlock_wrlock() - * pthread_rwlock_trywrlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" - -pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_rwlock_trywrlock(&rwlock1) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_rwlock_wrlock(&rwlock1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - Sleep(2000); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/rwlock4.c b/winsup/testsuite/winsup.api/pthread/rwlock4.c deleted file mode 100644 index 8cae52e6f..000000000 --- a/winsup/testsuite/winsup.api/pthread/rwlock4.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * rwlock4.c - * - * Declare a static rwlock object, rdlock it, trywrlock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_rwlock_rdlock() - * pthread_rwlock_trywrlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" - -pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_rwlock_trywrlock(&rwlock1) == EBUSY); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_rwlock_rdlock(&rwlock1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - Sleep(2000); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/rwlock5.c b/winsup/testsuite/winsup.api/pthread/rwlock5.c deleted file mode 100644 index 3ada946e3..000000000 --- a/winsup/testsuite/winsup.api/pthread/rwlock5.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * rwlock5.c - * - * - * Declare a static rwlock object, rdlock it, tryrdlock it, - * and then unlock it again. - * - * Depends on API functions: - * pthread_rwlock_rdlock() - * pthread_rwlock_tryrdlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" - -pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int washere = 0; - -void * func(void * arg) -{ - assert(pthread_rwlock_tryrdlock(&rwlock1) == 0); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - washere = 1; - - return 0; -} - -int -main() -{ - pthread_t t; - - assert(pthread_rwlock_rdlock(&rwlock1) == 0); - - assert(pthread_create(&t, NULL, func, NULL) == 0); - - Sleep(2000); - - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - assert(washere == 1); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/rwlock6.c b/winsup/testsuite/winsup.api/pthread/rwlock6.c deleted file mode 100644 index d5f2320d0..000000000 --- a/winsup/testsuite/winsup.api/pthread/rwlock6.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * rwlock6.c - * - * Check writer and reader locking - * - * Depends on API functions: - * pthread_rwlock_rdlock() - * pthread_rwlock_wrlock() - * pthread_rwlock_unlock() - */ - -#include "test.h" - -static pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; - -static int bankAccount = 0; - -void * wrfunc(void * arg) -{ - int ba; - - assert(pthread_rwlock_wrlock(&rwlock1) == 0); - Sleep(2000); - bankAccount += 10; - ba = bankAccount; - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - return ((void *) ba); -} - -void * rdfunc(void * arg) -{ - int ba; - - assert(pthread_rwlock_rdlock(&rwlock1) == 0); - ba = bankAccount; - assert(pthread_rwlock_unlock(&rwlock1) == 0); - - return ((void *) ba); -} - -int -main() -{ - pthread_t wrt1; - pthread_t wrt2; - pthread_t rdt; - int wr1Result = 0; - int wr2Result = 0; - int rdResult = 0; - - bankAccount = 0; - - assert(pthread_create(&wrt1, NULL, wrfunc, NULL) == 0); - Sleep(500); - assert(pthread_create(&rdt, NULL, rdfunc, NULL) == 0); - Sleep(500); - assert(pthread_create(&wrt2, NULL, wrfunc, NULL) == 0); - - assert(pthread_join(wrt1, (void **) &wr1Result) == 0); - assert(pthread_join(rdt, (void **) &rdResult) == 0); - assert(pthread_join(wrt2, (void **) &wr2Result) == 0); - - assert(wr1Result == 10); - assert(rdResult == 20); - assert(wr2Result == 20); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/rwlock7.c b/winsup/testsuite/winsup.api/pthread/rwlock7.c deleted file mode 100644 index 5b0727d99..000000000 --- a/winsup/testsuite/winsup.api/pthread/rwlock7.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * rwlock7.c - * - * Hammer on a bunch of rwlocks to test robustness and fairness. - * Printed stats should be roughly even for each thread. - */ - -#include "test.h" -#include -#include - -#ifdef __GNUC__ -#include -#endif - -#define THREADS 5 -#define DATASIZE 15 -#define ITERATIONS 1000000 - -#define rand_r( _seed ) \ - ( _seed == _seed? rand() : rand() ) - -/* - * Keep statistics for each thread. - */ -typedef struct thread_tag { - int thread_num; - pthread_t thread_id; - int updates; - int reads; - int interval; -} thread_t; - -/* - * Read-write lock and shared data - */ -typedef struct data_tag { - pthread_rwlock_t lock; - int data; - int updates; -} data_t; - -static thread_t threads[THREADS]; -static data_t data[DATASIZE]; - -/* - * Thread start routine that uses read-write locks - */ -void *thread_routine (void *arg) -{ - thread_t *self = (thread_t*)arg; - int repeats = 0; - int iteration; - int element = 0; - - for (iteration = 0; iteration < ITERATIONS; iteration++) - { - if (iteration % (ITERATIONS / 10) == 0) - { - putchar('.'); - fflush(stdout); - } - /* - * Each "self->interval" iterations, perform an - * update operation (write lock instead of read - * lock). - */ - if ((iteration % self->interval) == 0) - { - assert(pthread_rwlock_wrlock (&data[element].lock) == 0); - data[element].data = self->thread_num; - data[element].updates++; - self->updates++; - assert(pthread_rwlock_unlock (&data[element].lock) == 0); - } else { - /* - * Look at the current data element to see whether - * the current thread last updated it. Count the - * times, to report later. - */ - assert(pthread_rwlock_rdlock (&data[element].lock) == 0); - - self->reads++; - - if (data[element].data == self->thread_num) - { - repeats++; - } - - assert(pthread_rwlock_unlock (&data[element].lock) == 0); - } - - element++; - - if (element >= DATASIZE) - { - element = 0; - } - } - - if (repeats > 0) - { - printf ("\nThread %d found unchanged elements %d times", - self->thread_num, repeats); - fflush(stdout); - } - - return NULL; -} - -int -main (int argc, char *argv[]) -{ - int count; - int data_count; - int thread_updates = 0; - int data_updates = 0; - int seed = 1; - - struct timeb currSysTime1; - struct timeb currSysTime2; - - /* - * Initialize the shared data. - */ - for (data_count = 0; data_count < DATASIZE; data_count++) - { - data[data_count].data = 0; - data[data_count].updates = 0; - - assert(pthread_rwlock_init (&data[data_count].lock, NULL) == 0); - } - - ftime(&currSysTime1); - - /* - * Create THREADS threads to access shared data. - */ - for (count = 0; count < THREADS; count++) - { - threads[count].thread_num = count; - threads[count].updates = 0; - threads[count].reads = 0; - threads[count].interval = rand_r (&seed) % 71; - - assert(pthread_create (&threads[count].thread_id, - NULL, thread_routine, (void*)&threads[count]) == 0); - } - - /* - * Wait for all threads to complete, and collect - * statistics. - */ - for (count = 0; count < THREADS; count++) - { - assert(pthread_join (threads[count].thread_id, NULL) == 0); - thread_updates += threads[count].updates; - printf ("%02d: interval %d, updates %d, reads %d\n", - count, threads[count].interval, - threads[count].updates, threads[count].reads); - } - - putchar('\n'); - fflush(stdout); - - /* - * Collect statistics for the data. - */ - for (data_count = 0; data_count < DATASIZE; data_count++) - { - data_updates += data[data_count].updates; - printf ("data %02d: value %d, %d updates\n", - data_count, data[data_count].data, data[data_count].updates); - assert(pthread_rwlock_destroy (&data[data_count].lock) == 0); - } - - printf ("%d thread updates, %d data updates\n", - thread_updates, data_updates); - - ftime(&currSysTime2); - - printf( "\nstart: %ld/%d, stop: %ld/%d, duration:%ld\n", - currSysTime1.time,currSysTime1.millitm, - currSysTime2.time,currSysTime2.millitm, - (currSysTime2.time*1000+currSysTime2.millitm) - - (currSysTime1.time*1000+currSysTime1.millitm)); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/self1.c b/winsup/testsuite/winsup.api/pthread/self1.c deleted file mode 100644 index d46081830..000000000 --- a/winsup/testsuite/winsup.api/pthread/self1.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * self1.c - * - * Test for pthread_self(). - * - * Depends on API functions: - * pthread_self() - * - * Implicitly depends on: - * pthread_getspecific() - * pthread_setspecific() - */ - -#include "test.h" - -int -main(int argc, char * argv[]) -{ - /* - * This should always succeed unless the system has no - * resources (memory) left. - */ - assert(pthread_self() != NULL); - - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/self2.c b/winsup/testsuite/winsup.api/pthread/self2.c deleted file mode 100644 index 83339f101..000000000 --- a/winsup/testsuite/winsup.api/pthread/self2.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * self2.c - * - * Test for pthread_self(). - * - * Depends on API functions: - * pthread_create() - * pthread_self() - * - * Implicitly depends on: - * pthread_getspecific() - * pthread_setspecific() - */ - -#include "test.h" -#include - -static pthread_t me; - -void * -entry(void * arg) -{ - me = pthread_self(); - - return arg; -} - -int -main() -{ - pthread_t t; - - assert(pthread_create(&t, NULL, entry, NULL) == 0); - - Sleep(2000); - - /* - * Not much more we can do here but bytewise compare t with - * what pthread_self returned. - */ - assert(t == me); - assert(memcmp((const void *) t, (const void *) me, sizeof t) == 0); - - /* Success. */ - return 0; -} diff --git a/winsup/testsuite/winsup.api/pthread/test.h b/winsup/testsuite/winsup.api/pthread/test.h deleted file mode 100644 index 0e7246420..000000000 --- a/winsup/testsuite/winsup.api/pthread/test.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * test.h - * - * Useful definitions and declarations for tests. - */ - -#ifndef _PTHREAD_TEST_H_ -#define _PTHREAD_TEST_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* #define assert(x) do { fprint (stderr, "assertion failed\n"); exit(1) } while (0) */ - -const char * error_string[] = { - "ZERO_or_EOK", - "EPERM", - "ENOFILE_or_ENOENT", - "ESRCH", - "EINTR", - "EIO", - "ENXIO", - "E2BIG", - "ENOEXEC", - "EBADF", - "ECHILD", - "EAGAIN", - "ENOMEM", - "EACCES", - "EFAULT", - "UNKNOWN_15", - "EBUSY", - "EEXIST", - "EXDEV", - "ENODEV", - "ENOTDIR", - "EISDIR", - "EINVAL", - "ENFILE", - "EMFILE", - "ENOTTY", - "UNKNOWN_26", - "EFBIG", - "ENOSPC", - "ESPIPE", - "EROFS", - "EMLINK", - "EPIPE", - "EDOM", - "ERANGE", - "UNKNOWN_35", - "EDEADLOCK_or_EDEADLK", - "UNKNOWN_37", - "ENAMETOOLONG", - "ENOLCK", - "ENOSYS", - "ENOTEMPTY", - "EILSEQ", -}; - -/* - * The Mingw32 assert macro calls the CRTDLL _assert function - * which pops up a dialog. We want to run in batch mode so - * we define our own assert macro. - */ -#ifdef assert -# undef assert -#endif - -#ifdef NDEBUG - -# define assert(e) ((void)0) - -#else /* NDEBUG */ - -#ifndef ASSERT_TRACE -# define ASSERT_TRACE 0 -#else -# undef ASSERT_TRACE -# define ASSERT_TRACE 1 -#endif - -# define assert(e) \ - ((e) ? ((ASSERT_TRACE) ? fprintf(stderr, \ - "Assertion succeeded: (%s), file %s, line %d\n", \ - #e, __FILE__, (int) __LINE__), \ - fflush(stderr) : \ - 0) : \ - (fprintf(stderr, "Assertion failed: (%s), file %s, line %d\n", \ - #e, __FILE__, (int) __LINE__), exit(1), 0)) - -#endif /* NDEBUG */ - - -#endif diff --git a/winsup/testsuite/winsup.api/pthread/threadidafterfork.c b/winsup/testsuite/winsup.api/pthread/threadidafterfork.c deleted file mode 100644 index 473eaecfd..000000000 --- a/winsup/testsuite/winsup.api/pthread/threadidafterfork.c +++ /dev/null @@ -1,50 +0,0 @@ -#include -#include -#include -#include -#include - -static void * TestThread ( void * ); - -int main (void) -{ - pthread_t t; - - pthread_create (&t, NULL, TestThread, NULL); - pthread_join (t, NULL); - - return 0; -} - -static void * TestThread ( void *not_used ) -{ - pthread_t iAm = pthread_self(); - int status; - switch (fork ()) - { - case -1: - exit(1); - case 0: - if (iAm != pthread_self()) - exit (1); - else - exit (0); - break; - default: - wait (&status); - if (status != 0) - exit (1); - } - exit(0); -} - -/* -The forked child will not get the same thread handle as its parent, it -will get the thread handle from the main thread instead. The child will -not terminate because the threadcount is still 2 after the fork (it is -set to 1 in MTinterface::Init and then set back to 2 after the childs -memory gets overwritten by the parent). - -concept test by Thomas Pfaff -scritable test by Robert Collins -*/ diff --git a/winsup/testsuite/winsup.api/pthread/tsd1.c b/winsup/testsuite/winsup.api/pthread/tsd1.c deleted file mode 100644 index a65cf66c8..000000000 --- a/winsup/testsuite/winsup.api/pthread/tsd1.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * tsd1.c - * - * Test Thread Specific Data (TSD) key creation and destruction. - * - * Description: - * - - * - * Test Method (validation or falsification): - * - validation - * - * Requirements Tested: - * - keys are created for each existing thread including the main thread - * - keys are created for newly created threads - * - keys are thread specific - * - destroy routine is called on each thread exit including the main thread - * - * Features Tested: - * - - * - * Cases Tested: - * - - * - * Environment: - * - - * - * Input: - * - none - * - * Output: - * - text to stdout - * - * Assumptions: - * - already validated: pthread_create() - * pthread_once() - * - main thread also has a POSIX thread identity - * - * Pass Criteria: - * - stdout matches file reference/tsd1.out - * - * Fail Criteria: - * - fails to match file reference/tsd1.out - * - output identifies failed component - */ - -#include -#include "test.h" - -static pthread_key_t key = NULL; -static int accesscount[10]; -static int thread_set[10]; -static int thread_destroyed[10]; - -static void -destroy_key(void * arg) -{ - int * j = (int *) arg; - - (*j)++; - - assert(*j == 2); - - thread_destroyed[j - accesscount] = 1; -} - -static void -setkey(void * arg) -{ - int * j = (int *) arg; - - thread_set[j - accesscount] = 1; - - assert(*j == 0); - - assert(pthread_getspecific(key) == NULL); - - assert(pthread_setspecific(key, arg) == 0); - - assert(pthread_getspecific(key) == arg); - - (*j)++; - - assert(*j == 1); -} - -static void * -mythread(void * arg) -{ - while (key == NULL) - { - sched_yield(); - } - - setkey(arg); - - return 0; - - /* Exiting the thread will call the key destructor. */ -} - -int -main() -{ - int i; - int fail = 0; - pthread_t thread[10]; - - for (i = 1; i < 5; i++) - { - accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; - assert(pthread_create(&thread[i], NULL, mythread, (void *)&accesscount[i]) == 0); - } - - Sleep(2000); - - /* - * Here we test that existing threads will get a key created - * for them. - */ - assert(pthread_key_create(&key, destroy_key) == 0); - - /* - * Test main thread key. - */ - accesscount[0] = 0; - setkey((void *) &accesscount[0]); - - /* - * Here we test that new threads will get a key created - * for them. - */ - for (i = 5; i < 10; i++) - { - accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; - assert(pthread_create(&thread[i], NULL, mythread, (void *)&accesscount[i]) == 0); - } - - /* - * Wait for all threads to complete. - */ - for (i = 1; i < 10; i++) - { - int result = 0; - - assert(pthread_join(thread[i], (void **) &result) == 0); - } - - assert(pthread_key_delete(key) == 0); - - for (i = 1; i < 10; i++) - { - /* - * The counter is incremented once when the key is set to - * a value, and again when the key is destroyed. If the key - * doesn't get set for some reason then it will still be - * NULL and the destroy function will not be called, and - * hence accesscount will not equal 2. - */ - if (accesscount[i] != 2) - { - fail++; - fprintf(stderr, "Thread %d key, set = %d, destroyed = %d\n", - i, thread_set[i], thread_destroyed[i]); - } - } - - fflush(stderr); - - return (fail); -} diff --git a/winsup/testsuite/winsup.api/samples/sample-fail.c b/winsup/testsuite/winsup.api/samples/sample-fail.c deleted file mode 100644 index d0d3e4a6a..000000000 --- a/winsup/testsuite/winsup.api/samples/sample-fail.c +++ /dev/null @@ -1,5 +0,0 @@ -int -main() -{ - return 1; -} diff --git a/winsup/testsuite/winsup.api/samples/sample-miscompile.c b/winsup/testsuite/winsup.api/samples/sample-miscompile.c deleted file mode 100644 index bc0d21d2e..000000000 --- a/winsup/testsuite/winsup.api/samples/sample-miscompile.c +++ /dev/null @@ -1 +0,0 @@ -foo bar grill diff --git a/winsup/testsuite/winsup.api/samples/sample-pass.c b/winsup/testsuite/winsup.api/samples/sample-pass.c deleted file mode 100644 index 8e8f518aa..000000000 --- a/winsup/testsuite/winsup.api/samples/sample-pass.c +++ /dev/null @@ -1,5 +0,0 @@ -int -main() -{ - return 0; -} diff --git a/winsup/testsuite/winsup.api/semtest.c b/winsup/testsuite/winsup.api/semtest.c deleted file mode 100644 index dfb8c08eb..000000000 --- a/winsup/testsuite/winsup.api/semtest.c +++ /dev/null @@ -1,348 +0,0 @@ -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * Obtained from: $NetBSD: semtest.c,v 1.4 2002/07/20 08:36:25 grant Exp $ - * $FreeBSD: /repoman/r/ncvs/src/tools/regression/sysvsem/semtest.c,v 1.1 2002/08/15 06:34:37 alfred Exp $ - */ - -/* - * Test the SVID-compatible Semaphore facility. - */ - -/* - * CV, 2003-11-17: Add to Cygwin testsuite. - */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -const char *TCID = "semtest"; /* Test program identifier. */ -int TST_TOTAL = 54; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -int main (int, char *[]); -void print_semid_ds (struct semid_ds *, mode_t); -void sigsys_handler (int); -void sigchld_handler(int); -void cleanup (void); -void waiter (void); - -int sender_semid = -1; -pid_t child_pid; -int child_count; -int signal_was_sigchld; - -key_t semkey; - -/* - * This is the original semun union used by the sysvsem utility. - * It is deliberately kept here under #if 0'ed condition for future - * reference. PLEASE DO NOT REMOVE. The {SET,GET}ALL in FreeBSD - * are signed values, so the default version in sys/sem.h suffices. - */ -#if 1 /*0*/ -union semun { - int val; /* value for SETVAL */ - struct semid_ds *buf; /* buffer for IPC_{STAT,SET} */ - u_short *array; /* array for GETALL & SETALL */ -}; -#endif - -int -main(int argc, char *argv[]) -{ - struct sigaction sa; - union semun sun; - struct semid_ds s_ds; - sigset_t sigmask; - int i; - - Tst_count = 0; - - /* - * Install a SIGSYS handler so that we can exit gracefully if - * System V Semaphore support isn't in the kernel. - */ - sa.sa_handler = sigsys_handler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - if (sigaction(SIGSYS, &sa, NULL) == -1) - tst_brkm (TBROK, cleanup, "sigaction SIGSYS"); - - /* - * Install and SIGCHLD handler to deal with all possible exit - * conditions of the receiver. - */ - sa.sa_handler = sigchld_handler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - if (sigaction(SIGCHLD, &sa, NULL) == -1) - tst_brkm (TBROK, cleanup, "sigaction SIGCHLD"); - - semkey = ftok("/", 4160); - tst_resm (semkey == (key_t)-1 ? TFAIL : TPASS, - "ftok(\"/\") returns valid value"); - - /* - * Initialize child_pid to ourselves to that the cleanup function - * works before we create the receiver. - */ - child_pid = getpid(); - - sender_semid = semget(semkey, 1, IPC_CREAT | 0640); - tst_resm (sender_semid == -1 ? TFAIL : TPASS, "sender calls semget"); - - sun.buf = &s_ds; - tst_resm (semctl(sender_semid, 0, IPC_STAT, sun) == -1 ? TFAIL : TPASS, - "semctl IPC_STAT"); - - print_semid_ds(&s_ds, 0640); - - s_ds.sem_perm.mode = (s_ds.sem_perm.mode & ~0777) | 0600; - - sun.buf = &s_ds; - tst_resm (semctl(sender_semid, 0, IPC_SET, sun) == -1 ? TFAIL : TPASS, - "semctl IPC_SET"); - - memset(&s_ds, 0, sizeof(s_ds)); - - sun.buf = &s_ds; - tst_resm (semctl(sender_semid, 0, IPC_STAT, sun) == -1 ? TFAIL : TPASS, - "semctl IPC_STAT"); - - tst_resm ((s_ds.sem_perm.mode & 0777) != 0600 ? TFAIL : TPASS, - "IPC_SET of mode holds"); - - print_semid_ds(&s_ds, 0600); - - for (child_count = 0; child_count < 5; child_count++) { - switch ((child_pid = fork())) { - case -1: - tst_brkm (TBROK, cleanup, "fork"); - /* NOTREACHED */ - - case 0: - Tst_count += 22 + child_count * 4; - tst_resm (TPASS, "fork"); - waiter(); - break; - - default: - break; - } - } - - /* - * Wait for all of the waiters to be attempting to acquire the - * semaphore. - */ - for (;;) { - i = semctl(sender_semid, 0, GETNCNT); - if (i == -1) - tst_brkm (TBROK, cleanup, "semctl GETNCNT"); - if (i == 5) - break; - } - - /* - * Now set the thundering herd in motion by initializing the - * semaphore to the value 1. - */ - sun.val = 1; - tst_resm (semctl(sender_semid, 0, SETVAL, sun) == -1 ? TFAIL : TPASS, - "sender: semctl SETVAL to 1"); - - /* - * Suspend forever; when we get SIGCHLD, the handler will exit. - */ - sigemptyset(&sigmask); - for (;;) { - (void) sigsuspend(&sigmask); - if (signal_was_sigchld) - signal_was_sigchld = 0; - else - break; - } - - /* - * ...and any other signal is an unexpected error. - */ - - tst_brkm (TBROK, cleanup, "sender: received unexpected signal"); - exit (1); -} - -void -sigsys_handler(int signo) -{ - - tst_brkm (TBROK, cleanup, - "System V Semaphore support is not present in the kernel"); -} - -void -sigchld_handler(int signo) -{ - union semun sun; - struct semid_ds s_ds; - int cstatus; - - /* - * Reap the child; if it exited successfully, then we're on the - * right track! - */ - if (wait(&cstatus) == -1) - tst_brkm (TBROK, cleanup, "wait"); - - if (WIFEXITED(cstatus) == 0) - tst_brkm (TBROK, cleanup, "receiver exited abnormally"); - - if (WEXITSTATUS(cstatus) != 0) - tst_brkm (TBROK, cleanup, "receiver exited with status %d", - WEXITSTATUS(cstatus)); - - /* - * If we get here, the child has exited normally, and we should - * decrement the child count. If the child_count reaches 0, we - * should exit. - */ - - sun.buf = &s_ds; - tst_resm (semctl(sender_semid, 0, IPC_STAT, sun) == -1 ? TFAIL : TPASS, - "semctl IPC_STAT"); - - print_semid_ds(&s_ds, 0600); - - if (--child_count != 0) { - signal_was_sigchld = 1; - return; - } - - cleanup (); -} - -void -cleanup() -{ - - /* - * If we're the sender, and it exists, remove the message queue. - */ - if (child_pid != 0 && sender_semid != -1) { - tst_resm (semctl(sender_semid, 0, IPC_RMID) == -1 - ? TFAIL : TPASS, "semctl IPC_RMID"); - } - tst_exit (); -} - -void -print_semid_ds(struct semid_ds *sp, mode_t mode) -{ - uid_t uid = geteuid(); - gid_t gid = getegid(); - - printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n", - (int)sp->sem_perm.uid, (int)sp->sem_perm.gid, - (int)sp->sem_perm.cuid, (int)sp->sem_perm.cgid, - sp->sem_perm.mode & 0777); - - printf("nsems %u\n", sp->sem_nsems); - - printf("otime: %s", ctime(&sp->sem_otime)); - printf("ctime: %s", ctime(&sp->sem_ctime)); - - /* - * Sanity check a few things. - */ - - tst_resm (sp->sem_perm.uid != uid || sp->sem_perm.cuid != uid - ? TFAIL : TPASS, "uid matches"); - - tst_resm (sp->sem_perm.gid != gid || sp->sem_perm.cgid != gid - ? TFAIL : TPASS, "gid matches"); - - tst_resm ((sp->sem_perm.mode & 0777) != mode - ? TFAIL : TPASS, "mode matches"); -} - -void -waiter() -{ - struct sembuf s; - int semid; - - tst_resm ((semid = semget(semkey, 1, 0)) == -1 ? TFAIL : TPASS, - "waiter: semget"); - - /* - * Attempt to acquire the semaphore. - */ - s.sem_num = 0; - s.sem_op = -1; - s.sem_flg = SEM_UNDO; - - tst_resm (semop(semid, &s, 1) == -1 ? TFAIL : TPASS, - "waiter: semop -1"); - - printf("WOO! GOT THE SEMAPHORE!\n"); - sleep(1); - - /* - * Release the semaphore and exit. - */ - s.sem_num = 0; - s.sem_op = 1; - s.sem_flg = SEM_UNDO; - - tst_resm (semop(semid, &s, 1) == -1 ? TFAIL : TPASS, - "waiter: semop +1"); - - /* Allow parent to receive message before getting SIGCHLD. */ - sleep (1); - exit(0); -} diff --git a/winsup/testsuite/winsup.api/shmtest.c b/winsup/testsuite/winsup.api/shmtest.c deleted file mode 100644 index 54a2493a8..000000000 --- a/winsup/testsuite/winsup.api/shmtest.c +++ /dev/null @@ -1,293 +0,0 @@ -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * Obtained from: $NetBSD: shmtest.c,v 1.3 2002/07/20 08:36:26 grant Exp $ - * $FreeBSD: /repoman/r/ncvs/src/tools/regression/sysvshm/shmtest.c,v 1.1 2002/08/15 06:34:37 alfred Exp $ - */ - -/* - * Test the SVID-compatible Shared Memory facility. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "usctest.h" - -const char *TCID = "shmtest"; /* Test program identifier. */ -int TST_TOTAL = 22; /* Total number of test cases. */ -extern int Tst_count; /* Test Case counter for tst_* routines */ - -int main __P((int, char *[])); -void print_shmid_ds __P((struct shmid_ds *, mode_t)); -void sigsys_handler __P((int)); -void sigchld_handler __P((int)); -void cleanup __P((void)); -void receiver __P((void)); - -const char *m_str = "The quick brown fox jumped over the lazy dog."; - -int sender_shmid = -1; -pid_t child_pid; - -key_t shmkey; - -size_t pgsize; - -int -main(argc, argv) - int argc; - char *argv[]; -{ - struct sigaction sa; - struct shmid_ds s_ds; - sigset_t sigmask; - char *shm_buf; - - Tst_count = 0; - - /* - * Install a SIGSYS handler so that we can exit gracefully if - * System V Shared Memory support isn't in the kernel. - */ - sa.sa_handler = sigsys_handler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - if (sigaction(SIGSYS, &sa, NULL) == -1) - tst_brkm (TBROK, cleanup, "sigaction SIGSYS"); - - /* - * Install and SIGCHLD handler to deal with all possible exit - * conditions of the receiver. - */ - sa.sa_handler = sigchld_handler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - if (sigaction(SIGCHLD, &sa, NULL) == -1) - tst_brkm (TBROK, cleanup, "sigaction SIGCHLD"); - - pgsize = sysconf(_SC_PAGESIZE); - - shmkey = ftok("/", 4160); - tst_resm (shmkey == (key_t)-1 ? TFAIL : TPASS, - "ftok(\"/\") returns valid value"); - - /* - * Initialize child_pid to ourselves to that the cleanup function - * works before we create the receiver. - */ - child_pid = getpid(); - - sender_shmid = shmget(shmkey, pgsize, IPC_CREAT | 0640); - tst_resm (sender_shmid == -1 ? TFAIL : TPASS, "sender calls shmget"); - - tst_resm (shmctl(sender_shmid, IPC_STAT, &s_ds) == -1 ? TFAIL : TPASS, - "shmctl IPC_STAT"); - - print_shmid_ds(&s_ds, 0640); - - s_ds.shm_perm.mode = (s_ds.shm_perm.mode & ~0777) | 0600; - - tst_resm (shmctl(sender_shmid, IPC_SET, &s_ds) == -1 ? TFAIL : TPASS, - "shmctl IPC_SET"); - - memset(&s_ds, 0, sizeof(s_ds)); - - tst_resm (shmctl(sender_shmid, IPC_STAT, &s_ds) == -1 ? TFAIL : TPASS, - "shmctl IPC_STAT"); - - tst_resm ((s_ds.shm_perm.mode & 0777) != 0600 ? TFAIL : TPASS, - "IPC_SET of mode holds"); - - print_shmid_ds(&s_ds, 0600); - - tst_resm ((shm_buf = shmat(sender_shmid, NULL, 0)) == (void *) -1 - ? TFAIL : TPASS, "sender: shmat"); - - /* - * Write the test pattern into the shared memory buffer. - */ - strcpy(shm_buf, m_str); - - switch ((child_pid = fork())) { - case -1: - tst_brkm (TBROK, cleanup, "fork"); - /* NOTREACHED */ - - case 0: - tst_resm (TPASS, "fork"); - receiver(); - break; - - default: - Tst_count += 4; - break; - } - - /* - * Suspend forever; when we get SIGCHLD, the handler will exit. - */ - sigemptyset(&sigmask); - (void) sigsuspend(&sigmask); - - /* - * ...and any other signal is an unexpected error. - */ - tst_brkm (TBROK, cleanup, "sender: received unexpected signal"); - exit (1); -} - -void -sigsys_handler(signo) - int signo; -{ - - tst_brkm (TBROK, cleanup, - "System V Shared Memory support is not present in the kernel"); -} - -void -sigchld_handler(signo) - int signo; -{ - struct shmid_ds s_ds; - int cstatus; - - /* - * Reap the child; if it exited successfully, then the test passed! - */ - if (waitpid(child_pid, &cstatus, 0) != child_pid) - tst_brkm (TBROK, cleanup, "waitpid"); - - if (WIFEXITED(cstatus) == 0) - tst_brkm (TBROK, cleanup, "receiver exited abnormally"); - - if (WEXITSTATUS(cstatus) != 0) - tst_brkm (TBROK, cleanup, "receiver exited with status %d", - WEXITSTATUS(cstatus)); - - /* - * If we get here, the child has exited normally, and thus - * we should exit normally too. First, tho, we print out - * the final stats for the message queue. - */ - - tst_resm (shmctl(sender_shmid, IPC_STAT, &s_ds) == -1 ? TFAIL : TPASS, - "shmctl IPC_STAT"); - - print_shmid_ds(&s_ds, 0600); - - cleanup (); -} - -void -cleanup() -{ - - /* - * If we're the sender, and it exists, remove the shared memory area. - */ - if (child_pid != 0 && sender_shmid != -1) { - tst_resm (shmctl(sender_shmid, IPC_RMID, NULL) == -1 - ? TFAIL : TPASS, "shmctl IPC_RMID"); - } - tst_exit (); -} - -void -print_shmid_ds(sp, mode) - struct shmid_ds *sp; - mode_t mode; -{ - uid_t uid = geteuid(); - gid_t gid = getegid(); - - printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n", - (int)sp->shm_perm.uid, (int)sp->shm_perm.gid, - (int)sp->shm_perm.cuid, (int)sp->shm_perm.cgid, - sp->shm_perm.mode & 0777); - - printf("segsz %lu, lpid %d, cpid %d, nattch %u\n", - (u_long)sp->shm_segsz, sp->shm_lpid, sp->shm_cpid, - sp->shm_nattch); - - printf("atime: %s", ctime(&sp->shm_atime)); - printf("dtime: %s", ctime(&sp->shm_dtime)); - printf("ctime: %s", ctime(&sp->shm_ctime)); - - /* - * Sanity check a few things. - */ - - tst_resm (sp->shm_perm.uid != uid || sp->shm_perm.cuid != uid - ? TFAIL : TPASS, "uid matches"); - - tst_resm (sp->shm_perm.gid != gid || sp->shm_perm.cgid != gid - ? TFAIL : TPASS, "gid matches"); - - tst_resm ((sp->shm_perm.mode & 0777) != mode ? TFAIL : TPASS, - "mode matches"); -} - -void -receiver() -{ - int shmid; - void *shm_buf; - - tst_resm ((shmid = shmget(shmkey, pgsize, 0)) == -1 ? TFAIL : TPASS, - "receiver: shmget"); - - tst_resm ((shm_buf = shmat(shmid, NULL, 0)) == (void *) -1 - ? TFAIL : TPASS, "receiver: shmat"); - - printf("%s\n", (const char *)shm_buf); - tst_resm (strcmp((const char *)shm_buf, m_str) != 0 ? TFAIL : TPASS, - "receiver: data is correct"); - - exit(0); -} diff --git a/winsup/testsuite/winsup.api/sigchld.c b/winsup/testsuite/winsup.api/sigchld.c deleted file mode 100644 index b12876d4a..000000000 --- a/winsup/testsuite/winsup.api/sigchld.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include -#include - -int no_signal_caught = 1; - -void handler ( int signo ) -{ - no_signal_caught = 0; -} - -int -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/signal-into-win32-api.c b/winsup/testsuite/winsup.api/signal-into-win32-api.c deleted file mode 100755 index 26d0cd8e0..000000000 --- a/winsup/testsuite/winsup.api/signal-into-win32-api.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Test if signal is delivered to the application which is - * currently inside of native syscall - */ - -#include -#include -#include -#include -#include - -int saw_sigchld = 0; -int sleep_stage = -1; - -void -handle_child (int signo) -{ - printf ( "saw SIGCHLD, %d", sleep_stage); - saw_sigchld = 1; -} - -int -main (int argc, char** argv) -{ - pid_t pid; - if (argc > 1) - { - Sleep (200); - return 0; - } - - signal (SIGCHLD, handle_child); - pid = fork (); - if (pid < 0) - { - perror ( "fork" ); - return 2; - } - else if (pid == 0) - execl ( argv[0], argv[0], "child", 0 ); - else - { - sleep_stage = 0; - Sleep (3000); - sleep_stage = 1; - sleep (10); - sleep_stage = 2; - if (!saw_sigchld) - { - printf ( "oops\n" ); - kill (pid, SIGTERM); - return 1; - } - else - return 0; - } - exit (0); -} diff --git a/winsup/testsuite/winsup.api/systemcall.c b/winsup/testsuite/winsup.api/systemcall.c deleted file mode 100644 index 91dd748c0..000000000 --- a/winsup/testsuite/winsup.api/systemcall.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -int -main (int argc, char **argv) -{ - int fd, pid, n; - int fds[2]; - static char buf[4096]; - - close (0); - if ((fd = open ("/dev/null", O_WRONLY)) != 0) - { - fprintf (stderr, "couldn't redirect stdin to /dev/null, fd %d - %s\n", fd, strerror (errno)); - exit (1); - } - - close (1); - if ((fd = open ("/dev/null", O_WRONLY)) != 1) - { - fprintf (stderr, "couldn't redirect stdout to /dev/null, fd %d - %s\n", fd, strerror (errno)); - exit (1); - } - if (pipe (fds)) - { - fprintf (stderr, "pipe call failed - %s\n", strerror (errno)); - exit (1); - } - if ((pid = fork ()) == 0) - { - close (fds[0]); - if (dup2 (fds[1], 2) != 2) - { - fprintf (stderr, "couldn't redirect stderr to pipe - %s\n", strerror (errno)); - exit (1); - } - exit (system ("ls")); - } - else if (pid < 0) - { - perror ("couldn't fork"); - exit (1); - } - - close (fds[1]); - if (read (fds[0], buf, 4096) != 0) - { - fprintf (stderr, "system() call failed?\n%s\n", buf); - exit (1); - } - - if (waitpid (pid, &n, 0) < 0) - { - perror ("waitpid failed"); - exit (1); - } - if (n != 0) - { - fprintf (stderr, "system() call returned %p\n", (void *) n); - exit (1); - } - exit (0); -} diff --git a/winsup/testsuite/winsup.api/waitpid.c b/winsup/testsuite/winsup.api/waitpid.c deleted file mode 100644 index ee2925c4c..000000000 --- a/winsup/testsuite/winsup.api/waitpid.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include -#include -#include - -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 deleted file mode 100644 index e8eafad2e..000000000 --- a/winsup/testsuite/winsup.api/winsup.exp +++ /dev/null @@ -1,81 +0,0 @@ -source "site.exp" -source "$srcdir/winsup.api/known_bugs.tcl" - -if { ! [isnative] } { - verbose "skipping winsup.api because it's not native" - return -} - -set rv "" - -set ltp_includes "-I$ltp_includes" -set ltp_libs "$rootme/libltp.a" - -set add_includes $ltp_includes -set add_libs $ltp_libs - -set test_filter "" - -if { [info exists env(CYGWIN_TESTSUITE_TESTS)] } { - set test_filter "$env(CYGWIN_TESTSUITE_TESTS)" -} - -proc ws_spawn {cmd args} { - global rv - verbose "running $cmd\n" - catch "exec $cmd" rv - verbose send "catchCode = $rv\n" -} - -verbose "Filter: $test_filter" - -foreach src [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.c] { - if { $test_filter != "" && ! [regexp $test_filter $src] } { - verbose -log "Skipping $src" - continue - } - - regsub "^$srcdir/$subdir/" $src "" testcase - regsub ".c$" $testcase "" base - regsub ".*/" $base "" basename - regsub "/" $base "-" base - - if { [lsearch -exact $xfail_list $basename] >= 0 } { - set xfail_expected 1 - setup_xfail "*-*-*" - } else { - set xfail_expected 0 - clear_xfail - } - - ws_spawn "$CC -nodefaultlibs -nostdinc -mwin32 $CFLAGS $src $add_includes $add_libs $runtime_root/binmode.o -lgcc $runtime_root/libcygwin0.a -lkernel32 -luser32 -o $base.exe" - if { $rv != "" } { - verbose -log "$rv" - fail "$testcase (compile)" - } else { - if { $verbose } { - set redirect_output "./$base.log" - } else { - set redirect_output /dev/null - } - ws_spawn "$rootme/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" - if { ! $xfail_expected } { - catch { file delete "$base.exe" } err - if { $err != "" } { - note "error deleting $base.exe: $err" - } - } - } - } -} -- cgit v1.2.3