You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
(16) |
Apr
(25) |
May
(8) |
Jun
(22) |
Jul
(71) |
Aug
(36) |
Sep
(22) |
Oct
(31) |
Nov
(88) |
Dec
(40) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(128) |
Feb
(35) |
Mar
(28) |
Apr
(33) |
May
(18) |
Jun
(8) |
Jul
(21) |
Aug
(18) |
Sep
(6) |
Oct
(19) |
Nov
(12) |
Dec
(44) |
2012 |
Jan
(31) |
Feb
(48) |
Mar
(31) |
Apr
(11) |
May
(13) |
Jun
(15) |
Jul
(13) |
Aug
(18) |
Sep
(7) |
Oct
(25) |
Nov
(21) |
Dec
(13) |
2013 |
Jan
(17) |
Feb
(18) |
Mar
(21) |
Apr
(35) |
May
(30) |
Jun
(4) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(30) |
Nov
(13) |
Dec
|
From: Cyril H. <su...@li...> - 2013-10-22 18:51:07
|
The branch, master, has been updated via b968712a8cce12862e24d0461b073eaabe9cd3aa (commit) from 705926d096f7a64c9d53efeb789288e25457d68f (commit) - Log ----------------------------------------------------------------- commit b968712a8cce12862e24d0461b073eaabe9cd3aa Author: Cyril Hrubis <ch...@su...> Date: Tue Oct 22 19:50:31 2013 +0200 misc: remove tcore testcase After a little bit of internet archeology and it seems that patch which introduced /proc/sys/kernel/core_dump_threads file never got accepted into mainline linux kernel. (I found some discussion about it around linux 2.4 and 2.5 development.) So it looks like this test was never working on mainline kernels. Reported-by: C Nandi <cc...@ya...> Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: doc/testcases/misc.txt | 8 - runalltests.sh | 6 - runtest/tcore | 1 - testcases/misc/Makefile | 4 - testcases/misc/tcore_patch_test_suites/.gitignore | 1 - testcases/misc/tcore_patch_test_suites/Makefile | 36 ---- testcases/misc/tcore_patch_test_suites/tcore.c | 211 --------------------- testcases/misc/tcore_patch_test_suites/tcore.exp | 149 --------------- testcases/misc/tcore_patch_test_suites/tcore.sh | 144 -------------- 9 files changed, 0 insertions(+), 560 deletions(-) delete mode 100644 runtest/tcore delete mode 100644 testcases/misc/tcore_patch_test_suites/.gitignore delete mode 100644 testcases/misc/tcore_patch_test_suites/Makefile delete mode 100644 testcases/misc/tcore_patch_test_suites/tcore.c delete mode 100644 testcases/misc/tcore_patch_test_suites/tcore.exp delete mode 100755 testcases/misc/tcore_patch_test_suites/tcore.sh diff --git a/doc/testcases/misc.txt b/doc/testcases/misc.txt index 4568181..fff2598 100644 --- a/doc/testcases/misc.txt +++ b/doc/testcases/misc.txt @@ -121,11 +121,3 @@ ltp/testcases/misc/math/nextafter <\test_location> <\testname> -<testname=tcore_patch_test_suites> - <description> - Test suite for multi-thread core dump kernel patch. - <\description> - <test_location> - ltp/testcases/misc/tcore_patch_test_suites - <\test_location> -<\testname> diff --git a/runalltests.sh b/runalltests.sh index 45ea015..0c2c363 100755 --- a/runalltests.sh +++ b/runalltests.sh @@ -343,12 +343,6 @@ fi "${RUNLTP}" -f tpm_tools ## END => Test Series 7 ## -## The next one i plan to run is tcore_patch_test_suites -## START => Test Series 8 ## -"${RUNLTP}" -f tcore -## END => Test Series 8 ## - - ## The next one i plan to run is stress_cd tests ## START => Test Series 9 ## if [ $RUN_STRESS_CD -eq 1 ] diff --git a/runtest/tcore b/runtest/tcore deleted file mode 100644 index f9c8139..0000000 --- a/runtest/tcore +++ /dev/null @@ -1 +0,0 @@ -tcore01 tcore.sh diff --git a/testcases/misc/Makefile b/testcases/misc/Makefile index 2fcd649..d89cb9c 100644 --- a/testcases/misc/Makefile +++ b/testcases/misc/Makefile @@ -23,9 +23,5 @@ top_srcdir ?= ../.. -ifneq ($(WITH_EXPECT),yes) -FILTER_OUT_SUBDIRS := tcore_patch_test_suites -endif - include $(top_srcdir)/include/mk/env_pre.mk include $(top_srcdir)/include/mk/generic_trunk_target.mk diff --git a/testcases/misc/tcore_patch_test_suites/.gitignore b/testcases/misc/tcore_patch_test_suites/.gitignore deleted file mode 100644 index e47c402..0000000 --- a/testcases/misc/tcore_patch_test_suites/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/tcore diff --git a/testcases/misc/tcore_patch_test_suites/Makefile b/testcases/misc/tcore_patch_test_suites/Makefile deleted file mode 100644 index 85ec229..0000000 --- a/testcases/misc/tcore_patch_test_suites/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# -# misc/crash test suite Makefile. -# -# Copyright (C) 2009, Cisco Systems Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Garrett Cooper, July 2009 -# - -top_srcdir ?= ../../.. - -include $(top_srcdir)/include/mk/testcases.mk - -INSTALL_TARGETS := tcore.exp tcore.sh - -LDLIBS += -lm -lpthread - -MAKE_TARGETS := tcore - -#MODCFLAGS := -DLINUX -I$(prefix)/usr/src/linux/include -MODCFLAGS := -DLINUX - -include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/misc/tcore_patch_test_suites/tcore.c b/testcases/misc/tcore_patch_test_suites/tcore.c deleted file mode 100644 index 4578448..0000000 --- a/testcases/misc/tcore_patch_test_suites/tcore.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * - * Copyright (c) Min Guo <mi...@in...>., 2003 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -// Use gcc -o xmm xmm.c -pthread -lm to compile. -#include "test.h" -#include "usctest.h" - -/* Extern Global Variables */ -extern int tst_count; -extern char *TESTDIR; /* temporary dir created by tst_tmpdir() */ -/* Global Variables */ -char *TCID = "tcore"; /* test program identifier. */ - -#if defined __i386__ || defined(__x86_64__) -#include <stdio.h> -#include <sys/types.h> -#include <unistd.h> -#include <math.h> -#include <pthread.h> - -#define BUFFER_SIZE 16 - -int TST_TOTAL = 1; /* total number of tests in this file. */ - -/* Circular buffer of integers. */ - -struct prodcons { - int buffer[BUFFER_SIZE]; /* the actual data */ - pthread_mutex_t lock; /* mutex ensuring exclusive access to buffer */ - int readpos, writepos; /* positions for reading and writing */ - pthread_cond_t notempty; /* signaled when buffer is not empty */ - pthread_cond_t notfull; /* signaled when buffer is not full */ -}; - -/* Initialize a buffer */ -static void init(struct prodcons *b) -{ - pthread_mutex_init(&b->lock, NULL); - pthread_cond_init(&b->notempty, NULL); - pthread_cond_init(&b->notfull, NULL); - b->readpos = 0; - b->writepos = 0; -} - -/* Store an integer in the buffer */ -static void put(struct prodcons *b, int data) -{ - pthread_mutex_lock(&b->lock); - /* Wait until buffer is not full */ - while ((b->writepos + 1) % BUFFER_SIZE == b->readpos) { - pthread_cond_wait(&b->notfull, &b->lock); - /* pthread_cond_wait reacquired b->lock before returning */ - } - /* Write the data and advance write pointer */ - b->buffer[b->writepos] = data; - b->writepos++; - if (b->writepos >= BUFFER_SIZE) - b->writepos = 0; - /* Signal that the buffer is now not empty */ - pthread_cond_signal(&b->notempty); - pthread_mutex_unlock(&b->lock); -} - -/* Read and remove an integer from the buffer */ -static int get(struct prodcons *b) -{ - int data; - pthread_mutex_lock(&b->lock); - /* Wait until buffer is not empty */ - while (b->writepos == b->readpos) { - pthread_cond_wait(&b->notempty, &b->lock); - } - /* Read the data and advance read pointer */ - data = b->buffer[b->readpos]; - b->readpos++; - if (b->readpos >= BUFFER_SIZE) - b->readpos = 0; - /* Signal that the buffer is now not full */ - pthread_cond_signal(&b->notfull); - pthread_mutex_unlock(&b->lock); - return data; -} - -/* A test program: one thread inserts integers from 1 to 10000, - the other reads them and prints them. */ - -#define OVER (-1) - -struct prodcons buffer; - -static void *producer(void *data) -{ - int n; - pid_t pid; - long double a3 = 100.5678943, b3 = 200.578435698; - long double c3, d3, e3, f3; - a3 += b3; - a3 *= pow(b3, 2); - pid = getpid(); - tst_resm(TINFO, "producer pid=%d", pid); - sleep(1); - for (n = 0; n < 10000; n++) { - tst_resm(TINFO, "%d --->", n); - put(&buffer, n); - - if (n == 7686) { - system("ps ax | grep ex"); - c3 = pow(pid, pid); - d3 = log(pid); - e3 = c3 * d3; - f3 = c3 / d3; - { - char buf[16]; - sprintf(buf, "%d%d\n", pid, pid); - asm volatile ("movups (%0), %%xmm1;":: - "r" (buf):"memory"); - } - sleep(1); - } - } - put(&buffer, OVER); - return NULL; -} - -static void *consumer(void *data) -{ - int d; - char *junk = NULL; - pid_t pid; - long double a2 = 10002.5, b2 = 2888883.5; - long double d2, e2, f2; - a2 += b2; - pid = getpid(); - tst_resm(TINFO, "consumer pid=%d", pid); - sleep(1); - while (1) { - d = get(&buffer); - if (d == OVER) - break; - tst_resm(TINFO, "---> %d", d); - if (d == 7688) { - system("ps ax | grep ex"); - d2 = pid * a2 / b2; - e2 = tan(pid); - f2 = cos(pid) / d2; - { - char buf[16]; - char buf1[16]; - sprintf(buf, "%d%d\n", pid, pid); - sprintf(buf1, "%Lf", d2); - asm volatile ("movups (%0), %%xmm2;":: - "r" (buf):"memory"); - asm volatile ("movups (%0), %%xmm5;":: - "r" (buf):"memory"); - } - *junk = 0; - } - } - return NULL; -} - -int main(void) -{ - pthread_t th_a, th_b; - void *retval; - double a1 = 1.5, b1 = 2.5; - long double c1; - pid_t pid; - a1 += b1; - - pid = getpid(); - - init(&buffer); - /* Create the threads */ - pthread_create(&th_a, NULL, producer, 0); - pthread_create(&th_b, NULL, consumer, 0); - - c1 = exp(pid); - /* Wait until producer and consumer finish. */ - pthread_join(th_a, &retval); - pthread_join(th_b, &retval); - return 0; -} - -#else /* Not __i386__ */ - -int TST_TOTAL = 0; /* Total number of test cases. */ - -int main() -{ - tst_resm(TCONF, "tcore only works on x86 systems ..."); - tst_exit(); -} - -#endif /* __i386__ */ diff --git a/testcases/misc/tcore_patch_test_suites/tcore.exp b/testcases/misc/tcore_patch_test_suites/tcore.exp deleted file mode 100644 index 1a60dcc..0000000 --- a/testcases/misc/tcore_patch_test_suites/tcore.exp +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/expect -- - -# Copyright (c) Guo Min <mi...@in...>., 2002 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -set curr_thread 0 -set pass 0 -proc check_buf {buf key} { - set num 0 - for {} 1 {} { - set split_buf [split $buf ""] - set i [string first "\n" $buf] - if $i==-1 break; - set line [join [lrange $split_buf 0 $i] ""] - set buf [join [lrange $split_buf [expr 1+$i] end] ""] - set i [lsearch $line $key] - if -1!=$i { - incr num - } - } - return $num -} -proc check_threads {} { - global curr_thread - global pass - set istrue 0 - send "info threads\n" - expect { - -re " \[0-9\]+ process .*(gdb)" { - set buf $expect_out(0,string) - } - timeout { - puts stderr "timeout while run info threads" - return 1 - } - } - set curr_thread [check_buf $buf "process"] - if { $curr_thread == 0 } { - send_user "check_threads (no current thread)\n" - return 1 - } - if { $curr_thread >= 1 } { - set pass [expr $pass + 1] - send_user "the core dump includes multi thread information\n" - return 0 - } -} - -proc check_bt {} { - global curr_thread - global pass - set test 0 - set counter 1 - while { $counter <= $curr_thread } { - send "\n" - send "thread $counter\n" - expect { - -re "Switching to thread $counter .*\n" { - set buf $expect_out(0,string) - } - timeout { - send_user "timeout "; - return 1 - } - } - set number1 [check_buf $buf "(process"] - send "bt\n" - expect { - -re " bt.*#\[0-9\]+ .*(gdb)" { - set buf $expect_out(0,string) - } - } - set number [check_buf $buf "in"] - if { $number < 1 } { - set test 1 - } - set counter [expr $counter + 1] - } - if { 0 == $test } { - set pass [expr $pass + 1] - send_user "check bt in coredump successfully" - return 0 - } else { - send_user "check bt in coredump incorrectly" - return 1 - } - return 0 -} - -proc check_fpu {num} { - global expect_out - global pass - send "\n" - send "info register\n" - send "\n" - expect { - -re "xmm$num\[\t \]+\{f \= .*\}+\[\t \]+\{f \= .*\}" { - set buf $expect_out(0,string) - } - timeout { - puts stderr "fail to check the xmm value(timeout)" - return 1 - } - } - send "quit\n" - set buf_tmp [split $buf "\{"] - set buf1 [lindex $buf_tmp 4] - set buf2 [split $buf1 ","] - set number [lindex $buf2 1] - if { 0 != $number } { - set pass [expr $pass + 1] - send_user "success while check whether core dump includes fpu information" - return 0 - } else { - send_user "fail while check whether core dump includes fpu information" - return 1 - } -} -set GDB gdb -set binfile ./tcore -set corefile ./corefile - -spawn $GDB ${binfile} ${corefile} -check_fpu 5 -send "quit\n" - -spawn $GDB ${binfile} ${corefile} -check_threads -send "quit\n" - - -spawn $GDB ${binfile} ${corefile} -check_bt -send "quit\n" -exit $pass - diff --git a/testcases/misc/tcore_patch_test_suites/tcore.sh b/testcases/misc/tcore_patch_test_suites/tcore.sh deleted file mode 100755 index aad2b6b..0000000 --- a/testcases/misc/tcore_patch_test_suites/tcore.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/sh - -# Copyright (c) Guo Min <mi...@in...>., 2002 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -# Test suite for the t-core kernel patch -export TCID=tcore01 -PTHREAD_DIR="/lib/i686" -BIN_DIR=$LTPROOT/testcases/bin/ -TEST_DIR=$(mktemp -dt) -OSTYPE="redhat" -# Do some preparation to generate the correct core dump -# files -pass=0 -fail=0 -check_install() -{ - if [ -f /proc/sys/kernel/core_dumps_threads ];then - pass=`expr $pass + 1` - return 0 - else - fail=`expr $fail + 1` - return 1 - fi -} -os_check() -{ - if [ -d /usr/src/hardhat ];then - OSTYPE="hardhat" - fi -} - -cleanup() -{ - rm -rf $TEST_DIR - [ -f /proc/sys/kernel/core_dumps_threads ] && ! [ -z "$OLD_PATTERN" ] && - echo "$OLD_PATTERN" > /proc/sys/kernel/core_dumps_threads - exit $1 -} - -prepare_dump() -{ - ulimit -c 20000000 >/dev/null 2>&1 - # Open the core_dumps_threads key - if [ -f /proc/sys/kernel/core_dumps_threads ];then - m=`cat /proc/sys/kernel/core_dumps_threads` - if [ $m -eq 0 ];then - echo "1">/proc/sys/kernel/core_dumps_threads - fi - fi - if [ -f /proc/sys/kernel/core_pattern ]; then - OLD_PATTERN=$(cat /proc/sys/kernel/core_pattern) - echo 'core.%p' > /proc/sys/kernel/core_pattern - fi - #Recover the lipthread.so.0 lib to generate the correct - #core dump file - os_check - if [ $OSTYPE = "redhat" ];then - cd $PTHREAD_DIR && { - if [ -f libpthread.so.0.orig ];then - test=`ls -l libpthread.so.0.orig|awk '{print $11}'` - if [ $test = "libpthread-0.9.so" ];then - mv libpthread.so.0.orig libpthread.so.0 - fi - fi - cd - - } - fi -} -#Prepare for the gdb dump -prepare_gdb() -{ - os_check - if [ $OSTYPE = "redhat" ];then - cd $PTHREAD_DIR && { - if [ -f libpthread.so.0 ];then - test=`ls -l libpthread.so.0|awk '{print $11}'` - if [ $test = "libpthread-0.9.so" ];then - mv libpthread.so.0 libpthread.so.0.orig - fi - fi - ln -s /lib/libpthread.so.0 libpthread.so.0 >/dev/null 2>&1 - cd - - } - fi -} -#Test whether the system can generate the needed core files -#The core files should has pid as its extension -Test_gen_core() -{ - cd $TEST_DIR - prepare_dump - if [ -f core.* ];then - rm -f core.* - fi - pid=`$BIN_DIR/tcore |grep "consumer pid"|awk '{print $2}'|cut -d = -f 2` - echo "Test whether we can generate the needed core file" - if [ -f core.* ];then - echo "PASS" - pass=`expr $pass + 1` - return 0 - else - echo "FAIL" - fail=`expr $fail + 1` - return 1 - fi -} - -Test_core_file() -{ - cd $TEST_DIR - prepare_gdb - mv -f $TEST_DIR/core.* $TEST_DIR/corefile >/dev/null 2>&1 - echo "Test whether the core support bt,fpu and threads commands " - expect $BIN_DIR/tcore.exp - return=$? - pass=`expr $pass + $return` - fail=`expr 3 - $return + $fail` -} - -echo "Test Tcore patch " -check_install -Test_gen_core -Test_core_file -echo "Linux Tcore test results" > results -echo "Total pass fail" >> results -echo " 5 $pass $fail" >> results -cleanup $fail - - - hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-22 17:51:12
|
The branch, master, has been updated via 705926d096f7a64c9d53efeb789288e25457d68f (commit) via de8b8db9324b78e62f79b4c7eca7dc1ed570425c (commit) via e0f8585542dc0cab1a31c8d6a3e0c92b5206bef4 (commit) from 1e5da030e9cdeb431d41e7eb84658d9c4a5b67e3 (commit) - Log ----------------------------------------------------------------- commit 705926d096f7a64c9d53efeb789288e25457d68f Author: Stanislav Kholmanskikh <sta...@or...> Date: Mon Oct 21 11:25:17 2013 +0400 syscalls/setregid02: fixes It was a bug that the testcase initially changed its uid/gid to 'nobody' user but after performing setregid() It waited for 'users' gid. Fixed this. Also added 16-bit version check and performed minor cleanup. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit de8b8db9324b78e62f79b4c7eca7dc1ed570425c Author: Stanislav Kholmanskikh <sta...@or...> Date: Mon Oct 21 11:25:16 2013 +0400 syscalls/setregid{01, 03, 04}: 16-bit fixes and minor cleanup Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit e0f8585542dc0cab1a31c8d6a3e0c92b5206bef4 Author: Stanislav Kholmanskikh <sta...@or...> Date: Mon Oct 21 11:25:15 2013 +0400 syscalls/setreuid: 16-bit fixes and minor cleanup Signed-off-by: Stanislav Kholmanskikh <sta...@or...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/setregid/setregid01.c | 146 +++--------------- testcases/kernel/syscalls/setregid/setregid02.c | 143 +++++------------ testcases/kernel/syscalls/setregid/setregid03.c | 186 ++++++++--------------- testcases/kernel/syscalls/setregid/setregid04.c | 142 +++++------------- testcases/kernel/syscalls/setreuid/setreuid01.c | 173 +++------------------ testcases/kernel/syscalls/setreuid/setreuid02.c | 162 +++++-------------- testcases/kernel/syscalls/setreuid/setreuid03.c | 187 +++++++---------------- testcases/kernel/syscalls/setreuid/setreuid04.c | 145 +++++------------- testcases/kernel/syscalls/setreuid/setreuid05.c | 191 +++++++---------------- testcases/kernel/syscalls/setreuid/setreuid06.c | 108 ++++--------- testcases/kernel/syscalls/setreuid/setreuid07.c | 124 ++++++--------- testcases/kernel/syscalls/utils/compat_16.h | 9 + 12 files changed, 466 insertions(+), 1250 deletions(-) diff --git a/testcases/kernel/syscalls/setregid/setregid01.c b/testcases/kernel/syscalls/setregid/setregid01.c index a24177d..dae17bf 100644 --- a/testcases/kernel/syscalls/setregid/setregid01.c +++ b/testcases/kernel/syscalls/setregid/setregid01.c @@ -29,104 +29,30 @@ * * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ * + * Author: William Roske + * Co-pilot: Dave Fenner + */ + +/* + * Testcase to test the basic functionality of setregid(2) systemm call. */ -/* $Id: setregid01.c,v 1.6 2009/11/02 13:57:18 subrata_modak Exp $ */ -/********************************************************** - * - * OS Test - Silicon Graphics, Inc. - * - * TEST IDENTIFIER : setregid01 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Basic test for setregid(2) - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 5 - * - * WALL CLOCK TIME : 1 - * - * CPU TYPES : ALL - * - * AUTHOR : William Roske - * - * CO-PILOT : Dave Fenner - * - * DATE STARTED : 05/13/92 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * - * 1.) setregid(2) returns...(See Description) - * - * INPUT SPECIFICATIONS - * The standard options for system call tests are accepted. - * (See the parse_opts(3) man page). - * - * OUTPUT SPECIFICATIONS - * - * DURATION - * Terminates - with frequency and infinite modes. - * - * SIGNALS - * Uses SIGUSR1 to pause before test if option set. - * (See the parse_opts(3) man page). - * - * RESOURCES - * None - * - * ENVIRONMENTAL NEEDS - * No run-time environmental needs. - * - * SPECIAL PROCEDURAL REQUIREMENTS - * None - * - * INTERCASE DEPENDENCIES - * None - * - * DETAILED DESCRIPTION - * This is a Phase I test for the setregid(2) system call. It is intended - * to provide a limited exposure of the system call, for now. It - * should/will be extended when full functional tests are written for - * setregid(2). - * - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Otherwise, Issue a PASS message. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * - * - *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ #include <errno.h> #include <string.h> #include <signal.h> - #include <sys/types.h> #include "test.h" #include "usctest.h" +#include "compat_16.h" -void setup(); -void cleanup(); +static void setup(void); +static void cleanup(void); -char *TCID = "setregid01"; +TCID_DEFINE(setregid01); int TST_TOTAL = 5; -int exp_enos[] = { 0, 0 }; - -int gid, egid; /* current real and effective group id */ +static gid_t gid, egid; /* current real and effective group id */ int main(int ac, char **av) { @@ -138,9 +64,6 @@ int main(int ac, char **av) setup(); - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; @@ -150,12 +73,13 @@ int main(int ac, char **av) * Dont change either real or effective gid */ gid = getgid(); + GID16_CHECK(gid, setregid, cleanup); + egid = getegid(); + GID16_CHECK(egid, setregid, cleanup); - /* Call setregid(2) */ - TEST(setregid(-1, -1)); + TEST(SETREGID(cleanup, -1, -1)); - /* check return code */ if (TEST_RETURN == -1) { TEST_ERROR_LOG(TEST_ERRNO); tst_resm(TFAIL, @@ -163,7 +87,6 @@ int main(int ac, char **av) TEST_ERRNO, strerror(TEST_ERRNO)); } else { if (STD_FUNCTIONAL_TEST) { - /* No Verification test, yet... */ tst_resm(TPASS, "setregid - Dont change either real or effective gid returned %ld", TEST_RETURN); @@ -175,10 +98,8 @@ int main(int ac, char **av) * change effective to effective gid */ - /* Call setregid(2) */ - TEST(setregid(-1, egid)); + TEST(SETREGID(cleanup, -1, egid)); - /* check return code */ if (TEST_RETURN == -1) { TEST_ERROR_LOG(TEST_ERRNO); tst_resm(TFAIL, @@ -186,7 +107,6 @@ int main(int ac, char **av) TEST_ERRNO, strerror(TEST_ERRNO)); } else { if (STD_FUNCTIONAL_TEST) { - /* No Verification test, yet... */ tst_resm(TPASS, "setregid - change effective to effective gid returned %ld", TEST_RETURN); @@ -198,10 +118,8 @@ int main(int ac, char **av) * change real to real gid */ - /* Call setregid(2) */ - TEST(setregid(gid, -1)); + TEST(SETREGID(cleanup, gid, -1)); - /* check return code */ if (TEST_RETURN == -1) { TEST_ERROR_LOG(TEST_ERRNO); tst_resm(TFAIL, @@ -209,7 +127,6 @@ int main(int ac, char **av) TEST_ERRNO, strerror(TEST_ERRNO)); } else { if (STD_FUNCTIONAL_TEST) { - /* No Verification test, yet... */ tst_resm(TPASS, "setregid - change real to real gid returned %ld", TEST_RETURN); @@ -221,10 +138,8 @@ int main(int ac, char **av) * change effective to real gid */ - /* Call setregid(2) */ - TEST(setregid(-1, gid)); + TEST(SETREGID(cleanup, -1, gid)); - /* check return code */ if (TEST_RETURN == -1) { TEST_ERROR_LOG(TEST_ERRNO); tst_resm(TFAIL, @@ -232,7 +147,6 @@ int main(int ac, char **av) TEST_ERRNO, strerror(TEST_ERRNO)); } else { if (STD_FUNCTIONAL_TEST) { - /* No Verification test, yet... */ tst_resm(TPASS, "setregid - change effective to real gid returned %ld", TEST_RETURN); @@ -244,16 +158,13 @@ int main(int ac, char **av) * try to change real to current real */ - /* Call setregid(2) */ - TEST(setregid(gid, gid)); + TEST(SETREGID(cleanup, gid, gid)); - /* check return code */ if (TEST_RETURN == -1) { TEST_ERROR_LOG(TEST_ERRNO); tst_resm(TFAIL | TTERRNO, "setregid failed"); } else { if (STD_FUNCTIONAL_TEST) { - /* No Verification test, yet... */ tst_resm(TPASS, "setregid return %ld", TEST_RETURN); } @@ -263,34 +174,19 @@ int main(int ac, char **av) cleanup(); tst_exit(); - tst_exit(); - } -/*************************************************************** - * setup() - performs all ONE TIME setup for this test. - ***************************************************************/ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; - /* make a temp dir and cd to it */ tst_tmpdir(); } -/*************************************************************** - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - ***************************************************************/ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; tst_rmdir(); diff --git a/testcases/kernel/syscalls/setregid/setregid02.c b/testcases/kernel/syscalls/setregid/setregid02.c index 349a494..e67a7df 100644 --- a/testcases/kernel/syscalls/setregid/setregid02.c +++ b/testcases/kernel/syscalls/setregid/setregid02.c @@ -15,74 +15,34 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Ported by John George */ /* - * NAME - * setregid02.c - * - * DESCRIPTION - * Test that setregid() fails and sets the proper errno values when a - * non-root user attemps to change the real or effective group id to a - * value other than the current gid or the current effective gid. - * - * ALGORITHM - * - * Setup: - * Setup signal handling - * Get user information. - * Pause for SIGUSER1 if option specified. - * Setup test values. - * Loop if the proper options are given. - * For each test set execute the 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: <for command-line> - * setregid02 [-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 must be ran as root. - * users must be a valid group. + * Test that setregid() fails and sets the proper errno values when a + * non-root user attemps to change the real or effective group id to a + * value other than the current gid or the current effective gid. */ +#include <errno.h> #include <pwd.h> #include <grp.h> #include <stdlib.h> #include <string.h> + #include "test.h" #include "usctest.h" -#include <errno.h> +#include "compat_16.h" -char *TCID = "setregid02"; -gid_t users_gr_gid, root_gr_gid, bin_gr_gid; -gid_t neg_one = -1; -int exp_enos[] = { EPERM, 0 }; +TCID_DEFINE(setregid02); -gid_t inval_user = (USHRT_MAX); -char nobody_uid[] = "nobody"; -struct passwd *nobody; +static gid_t neg_one = -1; -struct group users, root, bin; -struct passwd *nobody; +static gid_t inval_user = (USHRT_MAX); +static struct passwd *ltpuser; + +static struct group nobody, root, bin; /* * The following structure contains all test data. Each structure in the array @@ -98,28 +58,28 @@ struct test_data_t { char *test_msg; } test_data[] = { { - &neg_one, &root_gr_gid, EPERM, &users, &users, + &neg_one, &root.gr_gid, EPERM, &nobody, &nobody, "After setregid(-1, root),"}, { - &neg_one, &bin_gr_gid, EPERM, &users, &users, + &neg_one, &bin.gr_gid, EPERM, &nobody, &nobody, "After setregid(-1, bin)"}, { - &root_gr_gid, &neg_one, EPERM, &users, &users, + &root.gr_gid, &neg_one, EPERM, &nobody, &nobody, "After setregid(root,-1),"}, { - &bin_gr_gid, &neg_one, EPERM, &users, &users, + &bin.gr_gid, &neg_one, EPERM, &nobody, &nobody, "After setregid(bin, -1),"}, { - &root_gr_gid, &bin_gr_gid, EPERM, &users, &users, + &root.gr_gid, &bin.gr_gid, EPERM, &nobody, &nobody, "After setregid(root, bin)"}, { - &bin_gr_gid, &root_gr_gid, EPERM, &users, &users, + &bin.gr_gid, &root.gr_gid, EPERM, &nobody, &nobody, "After setregid(bin, root),"}, { - &inval_user, &neg_one, EINVAL, &users, &users, + &inval_user, &neg_one, EINVAL, &nobody, &nobody, "After setregid(invalid group, -1),"}, { -&neg_one, &inval_user, EINVAL, &users, &users, + &neg_one, &inval_user, EINVAL, &nobody, &nobody, "After setregid(-1, invalid group),"},}; int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]); -void setup(void); -void cleanup(void); -void gid_verify(struct group *ru, struct group *eu, char *when); +static void setup(void); +static void cleanup(void); +static void gid_verify(struct group *ru, struct group *eu, char *when); int main(int ac, char **av) { @@ -134,12 +94,11 @@ int main(int ac, char **av) for (lc = 0; TEST_LOOPING(lc); lc++) { int i; - /* reset tst_count in case we are looping */ tst_count = 0; for (i = 0; i < TST_TOTAL; i++) { /* Set the real or effective group id */ - TEST(setregid(*test_data[i].real_gid, + TEST(SETREGID(cleanup, *test_data[i].real_gid, *test_data[i].eff_gid)); if (TEST_RETURN == -1) { @@ -169,10 +128,6 @@ int main(int ac, char **av) *test_data[i].real_gid, *test_data[i].eff_gid, TEST_RETURN); } - /* - * Perform functional verification if test - * executed without (-f) option. - */ if (STD_FUNCTIONAL_TEST) { gid_verify(test_data[i].exp_real_usr, test_data[i].exp_eff_usr, @@ -184,15 +139,9 @@ int main(int ac, char **av) } cleanup(); tst_exit(); - tst_exit(); - } -/* - * setup() - * performs all ONE TIME setup for this test - */ -void setup(void) +static void setup(void) { struct group *junk; @@ -200,62 +149,50 @@ void setup(void) tst_sig(FORK, DEF_HANDLER, cleanup); - if ((nobody = getpwnam("nobody")) == NULL) { + ltpuser = getpwnam("nobody"); + if (ltpuser == NULL) tst_brkm(TBROK, NULL, "getpwnam(\"nobody\") failed"); - } - if (setgid(nobody->pw_gid) == -1) { + if (setgid(ltpuser->pw_gid) == -1) { tst_brkm(TBROK | TERRNO, NULL, "setgid failed to set the effective gid to %d", - nobody->pw_gid); + ltpuser->pw_gid); } - if (setuid(nobody->pw_uid) == -1) { + if (setuid(ltpuser->pw_uid) == -1) { tst_brkm(TBROK | TERRNO, NULL, "setuid failed to to set the effective uid to %d", - nobody->pw_uid); + ltpuser->pw_uid); } - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - #define GET_GID(group) do { \ junk = getgrnam(#group); \ if (junk == NULL) { \ tst_brkm(TBROK|TERRNO, NULL, "getgrnam(\"%s\") failed", #group); \ } \ - group ## _gr_gid = junk->gr_gid;\ + GID16_CHECK(junk->gr_gid, setregid, NULL); \ + group = *(junk); \ } while (0) GET_GID(root); - GET_GID(users); + GET_GID(nobody); GET_GID(bin); - /* 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) +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; } void gid_verify(struct group *rg, struct group *eg, char *when) { if ((getgid() != rg->gr_gid) || (getegid() != eg->gr_gid)) { - tst_resm(TINFO, "ERROR: %s real gid = %d; effective gid = %d", + tst_resm(TFAIL, "ERROR: %s real gid = %d; effective gid = %d", when, getgid(), getegid()); tst_resm(TINFO, "Expected: real gid = %d; effective gid = %d", rg->gr_gid, eg->gr_gid); + } else { + tst_resm(TPASS, "real or effective gid was modified as expected"); } } diff --git a/testcases/kernel/syscalls/setregid/setregid03.c b/testcases/kernel/syscalls/setregid/setregid03.c index b9a5311..1cbdd52 100644 --- a/testcases/kernel/syscalls/setregid/setregid03.c +++ b/testcases/kernel/syscalls/setregid/setregid03.c @@ -1,65 +1,25 @@ /* + * Copyright (c) International Business Machines Corp., 2001 * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Ported by John George */ /* - * NAME - * setregid03.c - * - * DESCRIPTION - * Test setregid() when executed by a non-root user. - * - * ALGORITHM - * - * Setup: - * Setup signal handling - * Get user information. - * Pause for SIGUSER1 if option specified. - * Setup test values. - * Loop if the proper options are given. - * For each test set execute the 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: <for command-line> - * setregid03 [-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 must be ran as root. - * users, sys and bin must be valid groups. + * Test setregid() when executed by a non-root user. */ #include <errno.h> @@ -67,21 +27,19 @@ #include <stdlib.h> #include <pwd.h> #include <string.h> -#include "test.h" -#include "usctest.h" #include <sys/wait.h> -char *TCID = "setregid03"; -int fail = -1; -int pass = 0; -gid_t neg_one = -1; -int exp_enos[] = { 0 }; +#include "test.h" +#include "usctest.h" +#include "compat_16.h" -gid_t users_gr_gid, root_gr_gid, sys_gr_gid, bin_gr_gid; -uid_t nobody_pw_uid; +TCID_DEFINE(setregid03); +static int fail = -1; +static int pass; +static gid_t neg_one = -1; /* flag to tell parent if child passed or failed. */ -int flag = 0; +static int flag; struct group users, sys, root, bin; struct passwd nobody; @@ -99,33 +57,33 @@ struct test_data_t { char *test_msg; } test_data[] = { { - &sys_gr_gid, &bin_gr_gid, &pass, &sys, &bin, + &sys.gr_gid, &bin.gr_gid, &pass, &sys, &bin, "After setregid(sys, bin),"}, { - &neg_one, &sys_gr_gid, &pass, &sys, &sys, "After setregid(-1, sys)"}, + &neg_one, &sys.gr_gid, &pass, &sys, &sys, "After setregid(-1, sys)"}, { - &neg_one, &bin_gr_gid, &pass, &sys, &bin, "After setregid(-1, bin),"}, + &neg_one, &bin.gr_gid, &pass, &sys, &bin, "After setregid(-1, bin),"}, { - &bin_gr_gid, &neg_one, &pass, &bin, &bin, "After setregid(bin, -1),"}, + &bin.gr_gid, &neg_one, &pass, &bin, &bin, "After setregid(bin, -1),"}, { &neg_one, &neg_one, &pass, &bin, &bin, "After setregid(-1, -1),"}, { - &neg_one, &bin_gr_gid, &pass, &bin, &bin, "After setregid(-1, bin),"}, + &neg_one, &bin.gr_gid, &pass, &bin, &bin, "After setregid(-1, bin),"}, { - &bin_gr_gid, &neg_one, &pass, &bin, &bin, "After setregid(bin, -1),"}, + &bin.gr_gid, &neg_one, &pass, &bin, &bin, "After setregid(bin, -1),"}, { - &bin_gr_gid, &bin_gr_gid, &pass, &bin, &bin, + &bin.gr_gid, &bin.gr_gid, &pass, &bin, &bin, "After setregid(bin, bin),"}, { - &sys_gr_gid, &neg_one, &fail, &bin, &bin, "After setregid(sys, -1)"}, + &sys.gr_gid, &neg_one, &fail, &bin, &bin, "After setregid(sys, -1)"}, { - &neg_one, &sys_gr_gid, &fail, &bin, &bin, "After setregid(-1, sys)"}, + &neg_one, &sys.gr_gid, &fail, &bin, &bin, "After setregid(-1, sys)"}, { -&sys_gr_gid, &sys_gr_gid, &fail, &bin, &bin, + &sys.gr_gid, &sys.gr_gid, &fail, &bin, &bin, "After setregid(sys, sys)"},}; int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]); -void setup(void); -void cleanup(void); -void gid_verify(struct group *ru, struct group *eu, char *when); +static void setup(void); +static void cleanup(void); +static void gid_verify(struct group *ru, struct group *eu, char *when); int main(int ac, char **av) { @@ -141,24 +99,25 @@ int main(int ac, char **av) pid_t pid; int status, i; - /* reset tst_count in case we are looping */ + pass = 0; + flag = 0; + tst_count = 0; /* set the appropriate ownership values */ - if (setregid(sys_gr_gid, bin_gr_gid) == -1) { + if (SETREGID(cleanup, sys.gr_gid, bin.gr_gid) == -1) tst_brkm(TBROK, NULL, "Initial setregid failed"); - } - if (seteuid(nobody_pw_uid) == -1) { + if (seteuid(nobody.pw_uid) == -1) tst_brkm(TBROK, NULL, "Initial seteuid failed"); - } + if ((pid = FORK_OR_VFORK()) == -1) { tst_brkm(TBROK, NULL, "fork failed"); } else if (pid == 0) { /* child */ for (i = 0; i < TST_TOTAL; i++) { gid_t test_ret; /* Set the real or effective group id */ - TEST(setregid(*test_data[i].real_gid, + TEST(SETREGID(NULL, *test_data[i].real_gid, *test_data[i].eff_gid)); test_ret = TEST_RETURN; @@ -202,10 +161,6 @@ int main(int ac, char **av) TEST_ERROR_LOG(TEST_ERRNO); } - /* - * Perform functional verification if test - * executed without (-f) option. - */ if (STD_FUNCTIONAL_TEST) { gid_verify(test_data[i].exp_real_usr, test_data[i].exp_eff_usr, @@ -225,65 +180,50 @@ int main(int ac, char **av) } cleanup(); tst_exit(); - tst_exit(); - } -/* - * setup() - * performs all ONE TIME setup for this test - */ -void setup(void) +static void setup(void) { + struct group *junk; + tst_require_root(NULL); tst_sig(FORK, DEF_HANDLER, cleanup); - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - + if (getpwnam("nobody") == NULL) + tst_brkm(TBROK, NULL, "nobody must be a valid user."); nobody = *(getpwnam("nobody")); - nobody_pw_uid = nobody.pw_uid; - - root = *(getgrnam("root")); - root_gr_gid = root.gr_gid; - - users = *(getgrnam("users")); - users_gr_gid = users.gr_gid; - sys = *(getgrnam("sys")); - sys_gr_gid = sys.gr_gid; +#define GET_GID(group) do { \ + junk = getgrnam(#group); \ + if (junk == NULL) { \ + tst_brkm(TBROK, NULL, "%s must be a valid group", #group); \ + } \ + GID16_CHECK(junk->gr_gid, setregid, NULL); \ + group = *(junk); \ +} while (0) - bin = *(getgrnam("bin")); - bin_gr_gid = bin.gr_gid; + GET_GID(users); + GET_GID(sys); + GET_GID(bin); - /* 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) +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; } -void gid_verify(struct group *rg, struct group *eg, char *when) +static void gid_verify(struct group *rg, struct group *eg, char *when) { if ((getgid() != rg->gr_gid) || (getegid() != eg->gr_gid)) { - tst_resm(TINFO, "ERROR: %s real gid = %d; effective gid = %d", + tst_resm(TFAIL, "ERROR: %s real gid = %d; effective gid = %d", when, getgid(), getegid()); tst_resm(TINFO, "Expected: real gid = %d; effective gid = %d", rg->gr_gid, eg->gr_gid); flag = -1; + } else { + tst_resm(TPASS, "real or effective gid was modified as expected"); } } diff --git a/testcases/kernel/syscalls/setregid/setregid04.c b/testcases/kernel/syscalls/setregid/setregid04.c index ee1348c..7b343e2 100644 --- a/testcases/kernel/syscalls/setregid/setregid04.c +++ b/testcases/kernel/syscalls/setregid/setregid04.c @@ -1,81 +1,42 @@ /* + * Copyright (c) International Business Machines Corp., 2001 * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Ported by John George */ /* - * NAME - * setregid04.c - * - * DESCRIPTION - * Test setregid() when executed by root. - * - * ALGORITHM - * - * Setup: - * Setup signal handling - * Get user information. - * Pause for SIGUSER1 if option specified. - * Setup test values. - * Loop if the proper options are given. - * For each test set execute the 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: <for command-line> - * setregid04 [-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 must be ran as root. + * Test setregid() when executed by root. */ +#include <errno.h> #include <pwd.h> #include <grp.h> #include <stdlib.h> #include <string.h> + #include "test.h" #include "usctest.h" -#include <errno.h> +#include "compat_16.h" + +TCID_DEFINE(setregid04); -char *TCID = "setregid04"; -gid_t users_gr_gid, root_gr_gid, daemon_gr_gid, bin_gr_gid; -gid_t neg_one = -1; -int exp_enos[] = { 0 }; +static gid_t neg_one = -1; -/* Avoid clashing with daemon in unistd.h. */ -struct group users_gr, daemon_gr, root_gr, bin_gr; +static struct group users_gr, daemon_gr, root_gr, bin_gr; /* * The following structure contains all test data. Each structure in the array @@ -90,31 +51,31 @@ struct test_data_t { const char *test_msg; } test_data[] = { { - &root_gr_gid, &root_gr_gid, &root_gr, &root_gr, + &root_gr.gr_gid, &root_gr.gr_gid, &root_gr, &root_gr, "After setregid(root, root),"}, { - &users_gr_gid, &neg_one, &users_gr, &root_gr, + &users_gr.gr_gid, &neg_one, &users_gr, &root_gr, "After setregid(users, -1)"}, { - &root_gr_gid, &neg_one, &root_gr, &root_gr, + &root_gr.gr_gid, &neg_one, &root_gr, &root_gr, "After setregid(root,-1),"}, { &neg_one, &neg_one, &root_gr, &root_gr, "After setregid(-1, -1),"}, { - &neg_one, &root_gr_gid, &root_gr, &root_gr, + &neg_one, &root_gr.gr_gid, &root_gr, &root_gr, "After setregid(-1, root)"}, { - &root_gr_gid, &neg_one, &root_gr, &root_gr, + &root_gr.gr_gid, &neg_one, &root_gr, &root_gr, "After setregid(root, -1),"}, { - &daemon_gr_gid, &users_gr_gid, &daemon_gr, &users_gr, + &daemon_gr.gr_gid, &users_gr.gr_gid, &daemon_gr, &users_gr, "After setregid(daemon, users)"}, { &neg_one, &neg_one, &daemon_gr, &users_gr, "After setregid(-1, -1)"}, { - &neg_one, &users_gr_gid, &daemon_gr, &users_gr, + &neg_one, &users_gr.gr_gid, &daemon_gr, &users_gr, "After setregid(-1, users)"} }; int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]); -void setup(void); -void cleanup(void); -void gid_verify(struct group *ru, struct group *eu, const char *when); +static void setup(void); +static void cleanup(void); +static void gid_verify(struct group *ru, struct group *eu, const char *when); int main(int ac, char **av) { @@ -129,12 +90,11 @@ int main(int ac, char **av) for (lc = 0; TEST_LOOPING(lc); lc++) { int i; - /* reset tst_count in case we are looping */ tst_count = 0; for (i = 0; i < TST_TOTAL; i++) { /* Set the real or effective group id */ - TEST(setregid(*test_data[i].real_gid, + TEST(SETREGID(cleanup, *test_data[i].real_gid, *test_data[i].eff_gid)); if (TEST_RETURN == -1) { @@ -143,10 +103,6 @@ int main(int ac, char **av) *test_data[i].real_gid, *test_data[i].eff_gid); } else { - /* - * Perform functional verification if test - * executed without (-f) option. - */ if (STD_FUNCTIONAL_TEST) { gid_verify(test_data[i].exp_real_usr, test_data[i].exp_eff_usr, @@ -160,58 +116,34 @@ int main(int ac, char **av) cleanup(); tst_exit(); - tst_exit(); - } #define SAFE_GETGROUP(GROUPNAME) \ - if ((junk = getgrnam(#GROUPNAME)) == NULL) { \ + if (getgrnam(#GROUPNAME) == NULL) { \ tst_brkm(TBROK, NULL, "Couldn't find the `" #GROUPNAME "' group"); \ } \ - memcpy((void*) &GROUPNAME ## _gr, (const void*) junk, sizeof(struct group)); \ - GROUPNAME ## _gr_gid = GROUPNAME ## _gr.gr_gid + GROUPNAME ## _gr = *(getgrnam(#GROUPNAME)); -/* - * setup() - * performs all ONE TIME setup for this test - */ -void setup(void) +static void setup(void) { - struct group *junk; - tst_require_root(NULL); tst_sig(FORK, DEF_HANDLER, cleanup); - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); - SAFE_GETGROUP(root); SAFE_GETGROUP(users); SAFE_GETGROUP(daemon); SAFE_GETGROUP(bin); - /* 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) +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; } -void gid_verify(struct group *rg, struct group *eg, const char *when) +static void gid_verify(struct group *rg, struct group *eg, const char *when) { if ((getgid() != rg->gr_gid) || (getegid() != eg->gr_gid)) { tst_resm(TFAIL, "ERROR: %s real gid = %d; effective gid = %d", diff --git a/testcases/kernel/syscalls/setreuid/setreuid01.c b/testcases/kernel/syscalls/setreuid/setreuid01.c index 1f54337..18b5ed0 100644 --- a/testcases/kernel/syscalls/setreuid/setreuid01.c +++ b/testcases/kernel/syscalls/setreuid/setreuid01.c @@ -29,127 +29,41 @@ * * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ * + * Author: William Roske + * Co-pilot: Dave Fenner + */ + +/* + * Testcase to test the basic functionality of setreuid(2) system call. */ -/* $Id: setreuid01.c,v 1.6 2009/11/02 13:57:18 subrata_modak Exp $ */ -/********************************************************** - * - * OS Test - Silicon Graphics, Inc. - * - * TEST IDENTIFIER : setreuid01 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Basic test for setreuid(2) - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 5 - * - * WALL CLOCK TIME : 1 - * - * CPU TYPES : ALL - * - * AUTHOR : William Roske - * - * CO-PILOT : Dave Fenner - * - * DATE STARTED : 05/14/92 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * - * 1.) setreuid(2) returns...(See Description) - * - * INPUT SPECIFICATIONS - * The standard options for system call tests are accepted. - * (See the parse_opts(3) man page). - * - * OUTPUT SPECIFICATIONS - * - * DURATION - * Terminates - with frequency and infinite modes. - * - * SIGNALS - * Uses SIGUSR1 to pause before test if option set. - * (See the parse_opts(3) man page). - * - * RESOURCES - * None - * - * ENVIRONMENTAL NEEDS - * No run-time environmental needs. - * - * SPECIAL PROCEDURAL REQUIREMENTS - * None - * - * INTERCASE DEPENDENCIES - * None - * - * DETAILED DESCRIPTION - * This is a Phase I test for the setreuid(2) system call. It is intended - * to provide a limited exposure of the system call, for now. It - * should/will be extended when full functional tests are written for - * setreuid(2). - * - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Otherwise, Issue a PASS message. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * - * - *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ #include <errno.h> #include <string.h> #include <signal.h> - #include <sys/types.h> #include "test.h" #include "usctest.h" +#include "compat_16.h" -void setup(); -void cleanup(); +static void setup(void); +static void cleanup(void); -char *TCID = "setreuid01"; +TCID_DEFINE(setreuid01); int TST_TOTAL = 5; -int exp_enos[] = { 0, 0 }; - -int ruid, euid; /* real and effective user ids */ +static uid_t ruid, euid; /* real and effective user ids */ int main(int ac, char **av) { int lc; char *msg; - /*************************************************************** - * parse standard options - ***************************************************************/ if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "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++) { tst_count = 0; @@ -159,21 +73,19 @@ int main(int ac, char **av) * Don't change either real or effective uid */ ruid = getuid(); /* get real uid */ + UID16_CHECK(ruid, setreuid, cleanup); + euid = geteuid(); /* get effective uid */ + UID16_CHECK(euid, setreuid, cleanup); - /* Call setreuid(2) */ - TEST(setreuid(-1, -1)); + TEST(SETREUID(cleanup, -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, @@ -187,21 +99,15 @@ int main(int ac, char **av) * change effective to effective uid */ - /* Call setreuid(2) */ - TEST(setreuid(-1, euid)); + TEST(SETREUID(cleanup, -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 %ld", TEST_RETURN); @@ -213,21 +119,15 @@ int main(int ac, char **av) * change real to real uid */ - /* Call setreuid(2) */ - TEST(setreuid(ruid, -1)); + TEST(SETREUID(cleanup, 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 %ld", TEST_RETURN); @@ -239,21 +139,15 @@ int main(int ac, char **av) * change effective to real uid */ - /* Call setreuid(2) */ - TEST(setreuid(-1, ruid)); + TEST(SETREUID(cleanup, -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 %ld", TEST_RETURN); @@ -265,21 +159,15 @@ int main(int ac, char **av) * try to change real to current real */ - /* Call setreuid(2) */ - TEST(setreuid(ruid, ruid)); + TEST(SETREUID(cleanup, 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 %ld", TEST_RETURN); @@ -288,41 +176,22 @@ int main(int ac, char **av) } - /*************************************************************** - * cleanup and exit - ***************************************************************/ cleanup(); tst_exit(); - tst_exit(); - } -/*************************************************************** - * setup() - performs all ONE TIME setup for this test. - ***************************************************************/ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; - /* make a temp dir and cd to it */ tst_tmpdir(); } -/*************************************************************** - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - ***************************************************************/ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; tst_rmdir(); - } diff --git a/testcases/kernel/syscalls/setreuid/setreuid02.c b/testcases/kernel/syscalls/setreuid/setreuid02.c index 5fdd918..1263996 100644 --- a/testcases/kernel/syscalls/setreuid/setreuid02.c +++ b/testcases/kernel/syscalls/setreuid/setreuid02.c @@ -1,87 +1,47 @@ /* + * Copyright (c) International Business Machines Corp., 2001 * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Ported by John George */ /* - * NAME - * setreuid02.c - * - * DESCRIPTION - * Test setreuid() when executed by root. - * - * ALGORITHM - * - * Setup: - * Setup signal handling - * Get user information. - * Pause for SIGUSER1 if option specified. - * Setup test values. - * Loop if the proper options are given. - * For each test set execute the 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: <for command-line> - * setreuid02 [-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 must be ran as root. - * nobody, bin, and daemon must be valid users. + * Test setreuid() when executed by root. */ +#include <errno.h> #include <pwd.h> #include <stdlib.h> #include <string.h> + #include "test.h" #include "usctest.h" -#include <errno.h> +#include "compat_16.h" -char *TCID = "setreuid02"; -uid_t nobody_pw_uid, root_pw_uid, daemon_pw_uid, bin_pw_uid; -uid_t neg_one = -1; -int exp_enos[] = { 0 }; +TCID_DEFINE(setreuid02); -struct passwd nobody, daemonpw, root, bin; +static uid_t neg_one = -1; +static struct passwd nobody, daemonpw, root, bin; /* * The following structure contains all test data. Each structure in the array * is used for a separate test. The tests are executed in the for loop below. */ -struct test_data_t { +static struct test_data_t { uid_t *real_uid; uid_t *eff_uid; struct passwd *exp_real_usr; @@ -90,42 +50,39 @@ struct test_data_t { } test_data[] = { { &neg_one, &neg_one, &root, &root, "After setreuid(-1, -1),"}, { - &nobody_pw_uid, &neg_one, &nobody, &root, "After setreuid(nobody, -1)"}, + &nobody.pw_uid, &neg_one, &nobody, &root, "After setreuid(nobody, -1)"}, { - &root_pw_uid, &neg_one, &root, &root, "After setreuid(root,-1),"}, { - &neg_one, &daemon_pw_uid, &root, &daemonpw, + &root.pw_uid, &neg_one, &root, &root, "After setreuid(root,-1),"}, { + &neg_one, &daemonpw.pw_uid, &root, &daemonpw, "After setreuid(-1, daemon)"}, { - &neg_one, &root_pw_uid, &root, &root, "After setreuid(-1,root),"}, { - &bin_pw_uid, &neg_one, &bin, &root, "After setreuid(bin, -1)"}, { -&root_pw_uid, &neg_one, &root, &root, "After setreuid(-1, root)"},}; + &neg_one, &root.pw_uid, &root, &root, "After setreuid(-1,root),"}, { + &bin.pw_uid, &neg_one, &bin, &root, "After setreuid(bin, -1)"}, { +&root.pw_uid, &neg_one, &root, &root, "After setreuid(-1, root)"},}; int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]); -void setup(void); -void cleanup(void); -void uid_verify(struct passwd *ru, struct passwd *eu, char *when); +static void setup(void); +static void cleanup(void); +static void uid_verify(struct passwd *ru, struct passwd *eu, char *when); int main(int ac, char **av) { int lc; char *msg; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } - setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { int i; - /* reset tst_count in case we are looping */ tst_count = 0; for (i = 0; i < TST_TOTAL; i++) { /* Set the real or effective user id */ - TEST(setreuid(*test_data[i].real_uid, + TEST(SETREUID(cleanup, *test_data[i].real_uid, *test_data[i].eff_uid)); if (TEST_RETURN == -1) { @@ -134,10 +91,6 @@ int main(int ac, char **av) *test_data[i].real_uid, *test_data[i].eff_uid); } else { - /* - * Perform functional verification if test - * executed without (-f) option. - */ if (STD_FUNCTIONAL_TEST) { uid_verify(test_data[i].exp_real_usr, test_data[i].exp_eff_usr, @@ -150,71 +103,44 @@ int main(int ac, char **av) } cleanup(); tst_exit(); - } -/* - * setup() - * performs all ONE TIME setup for this test - */ -void setup(void) +static void setup(void) { + tst_require_root(NULL); tst_sig(FORK, DEF_HANDLER, cleanup); - if (getpwnam("nobody") == NULL) { + if (getpwnam("nobody") == NULL) tst_brkm(TBROK, NULL, "nobody must be a valid user."); - tst_exit(); - } - if (getpwnam("daemon") == NULL) { + if (getpwnam("daemon") == NULL) tst_brkm(TBROK, NULL, "daemon must be a valid user."); - tst_exit(); - } - /* Check that the test process id is root */ - if (geteuid() != 0) { - tst_brkm(TBROK, NULL, "Must be root for this test!"); - tst_exit(); - } - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); + if (getpwnam("bin") == NULL) + tst_brkm(TBROK, NULL, "bin must be a valid user."); root = *(getpwnam("root")); - root_pw_uid = root.pw_uid; + UID16_CHECK(root.pw_uid, setreuid, cleanup); nobody = *(getpwnam("nobody")); - nobody_pw_uid = nobody.pw_uid; + UID16_CHECK(nobody.pw_uid, setreuid, cleanup); daemonpw = *(getpwnam("daemon")); - daemon_pw_uid = daemonpw.pw_uid; + UID16_CHECK(daemonpw.pw_uid, setreuid, cleanup); bin = *(getpwnam("bin")); - bin_pw_uid = bin.pw_uid; + UID16_CHECK(bin.pw_uid, setreuid, 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) +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; - } -void uid_verify(struct passwd *ru, struct passwd *eu, char *when) +static void uid_verify(struct passwd *ru, struct passwd *eu, char *when) { if ((getuid() != ru->pw_uid) || (geteuid() != eu->pw_uid)) { tst_resm(TFAIL, "ERROR: %s real uid = %d; effective uid = %d", diff --git a/testcases/kernel/syscalls/setreuid/setreuid03.c b/testcases/kernel/syscalls/setreuid/setreuid03.c index 5dcb1f6..1074e79 100644 --- a/testcases/kernel/syscalls/setreuid/setreuid03.c +++ b/testcases/kernel/syscalls/setreuid/setreuid03.c @@ -1,94 +1,52 @@ /* * - * Copyright (c) International Business Machines Corp., 2001 + * 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 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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Ported by John George */ /* - * NAME - * setreuid03.c - * - * DESCRIPTION - * Test setreuid() when executed by an unpriviledged user. - * - * ALGORITHM - * - * Setup: - * Setup signal handling - * Get user information. - * Pause for SIGUSER1 if option specified. - * - * Setup test values. - * Loop if the proper options are given. - * For each test set execute the system call - * Check that we received the expected result. - * If setreuid failed as expected - * check that the correct errno value was set. - * otherwise - * Issue Pass message. - * Verify that the uid and euid values are still correct. - * Cleanup: - * Print errno log and/or timing stats if option given. - * - * USAGE: <for command-line> - * setreuid03 [-c n] [-f] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -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 must be run by nobody. + * Test setreuid() when executed by an unpriviledged user. */ +#include <errno.h> #include <pwd.h> #include <stdlib.h> + #include "test.h" #include "usctest.h" -#include <errno.h> +#include "compat_16.h" #define FAILED 1 -char *TCID = "setreuid03"; - -int fail = -1; -int pass = 0; -uid_t neg_one = -1; -int exp_enos[] = { EPERM, 0 }; +TCID_DEFINE(setreuid03); -uid_t root_pw_uid, nobody_pw_uid, bin_pw_uid; -char user1name[] = "nobody"; -char user2name[] = "bin"; -char rootname[] = "root"; +static int fail = -1; +static int pass; +static uid_t neg_one = -1; -struct passwd nobody, bin, root; +static struct passwd nobody, bin, root; /* * The following structure contains all test data. Each structure in the array * is used for a separate test. The tests are executed in the for loop below. */ -struct test_data_t { +static struct test_data_t { uid_t *real_uid; uid_t *eff_uid; int *exp_ret; @@ -97,63 +55,60 @@ struct test_data_t { char *test_msg; } test_data[] = { { - &nobody_pw_uid, &nobody_pw_uid, &pass, &nobody, &nobody, + &nobody.pw_uid, &nobody.pw_uid, &pass, &nobody, &nobody, "After setreuid(nobody, nobody),"}, { - &neg_one, &nobody_pw_uid, &pass, &nobody, &nobody, + &neg_one, &nobody.pw_uid, &pass, &nobody, &nobody, "After setreuid(-1, nobody),"}, { - &nobody_pw_uid, &neg_one, &pass, &nobody, &nobody, + &nobody.pw_uid, &neg_one, &pass, &nobody, &nobody, "After setreuid(nobody, -1),"}, { &neg_one, &neg_one, &pass, &nobody, &nobody, "After setreuid(-1, -1),"}, { - &neg_one, &root_pw_uid, &fail, &nobody, &nobody, + &neg_one, &root.pw_uid, &fail, &nobody, &nobody, "After setreuid(-1, root),"}, { - &root_pw_uid, &neg_one, &fail, &nobody, &nobody, + &root.pw_uid, &neg_one, &fail, &nobody, &nobody, "After setreuid(root, -1),"}, { - &root_pw_uid, &root_pw_uid, &fail, &nobody, &nobody, + &root.pw_uid, &root.pw_uid, &fail, &nobody, &nobody, "After setreuid(root, root),"}, { - &root_pw_uid, &nobody_pw_uid, &fail, &nobody, &nobody, + &root.pw_uid, &nobody.pw_uid, &fail, &nobody, &nobody, "After setreuid(root, nobody),"}, { - &root_pw_uid, &bin_pw_uid, &fail, &nobody, &nobody, + &root.pw_uid, &bin.pw_uid, &fail, &nobody, &nobody, "After setreuid(root, nobody),"}, { - &bin_pw_uid, &root_pw_uid, &fail, &nobody, &nobody, + &bin.pw_uid, &root.pw_uid, &fail, &nobody, &nobody, "After setreuid(bin, root),"}, { - &bin_pw_uid, &neg_one, &fail, &nobody, &nobody, + &bin.pw_uid, &neg_one, &fail, &nobody, &nobody, "After setreuid(bin, -1),"}, { - &bin_pw_uid, &bin_pw_uid, &fail, &nobody, &nobody, + &bin.pw_uid, &bin.pw_uid, &fail, &nobody, &nobody, "After setreuid(bin, bin,),"}, { - &bin_pw_uid, &nobody_pw_uid, &fail, &nobody, &nobody, + &bin.pw_uid, &nobody.pw_uid, &fail, &nobody, &nobody, "After setreuid(bin, nobody),"}, { -&nobody_pw_uid, &bin_pw_uid, &fail, &nobody, &nobody, + &nobody.pw_uid, &bin.pw_uid, &fail, &nobody, &nobody, "After setreuid(nobody, bin),"},}; int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]); -void setup(void); -void cleanup(void); -void uid_verify(struct passwd *, struct passwd *, char *); +static void setup(void); +static void cleanup(void); +static void uid_verify(struct passwd *, struct passwd *, char *); int main(int ac, char **av) { int lc; char *msg; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } - setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { int i; - /* reset tst_count in case we are looping */ tst_count = 0; for (i = 0; i < TST_TOTAL; i++) { /* Set the real or effective user id */ - TEST(setreuid(*test_data[i].real_uid, + TEST(SETREUID(cleanup, *test_data[i].real_uid, *test_data[i].eff_uid)); if (TEST_RETURN == *test_data[i].exp_ret) { @@ -187,86 +142,56 @@ int main(int ac, char **av) if (TEST_RETURN == -1) { TEST_ERROR_LOG(TEST_ERRNO); } - /* - * Perform functional verification if test - * executed without (-f) option. - */ if (STD_FUNCTIONAL_TEST) { uid_verify(test_data[i].exp_real_usr, test_data[i].exp_eff_usr, test_data[i].test_msg); + } else { + tst_resm(TINFO, "Call succeeded."); } } } cleanup(); tst_exit(); - } -/* - * setup() - * performs all ONE TIME setup for this test - */ -void setup(void) +static void setup(void) { + tst_require_root(NULL); tst_sig(FORK, DEF_HANDLER, cleanup); - if (getpwnam("nobody") == NULL) { + if (getpwnam("nobody") == NULL) tst_brkm(TBROK, NULL, "nobody must be a valid user."); - tst_exit(); - } - if (getpwnam("bin") == NULL) { + if (getpwnam("bin") == NULL) tst_brkm(TBROK, NULL, "bin must be a valid user."); - tst_exit(); - } - - /* set the expected errnos... */ - TEST_EXP_ENOS(exp_enos); root = *(getpwnam("root")); - root_pw_uid = root.pw_uid; + UID16_CHECK(root.pw_uid, setreuid, cleanup); nobody = *(getpwnam("nobody")); - nobody_pw_uid = nobody.pw_uid; + UID16_CHECK(nobody.pw_uid, setreuid, cleanup); bin = *(getpwnam("bin")); - bin_pw_uid = bin.pw_uid; + UID16_CHECK(bin.pw_uid, setreuid, cleanup); - /* Check that the test process id is nobody */ - if (geteuid() != nobody.pw_uid) { -/* tst_brkm(TBROK, NULL, "Must be nobody for this test!"); - tst_exit();*/ - setuid(nobody.pw_uid); - } + if (setuid(nobody.pw_uid) < 0) + tst_brkm(TBROK | TERRNO, NULL, "setuid() to nobody failed"); - /* 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) +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; - } -void uid_verify(struct passwd *ru, struct passwd *eu, char *when) +static void uid_verify(struct passwd *ru, struct passwd *eu, char *when) { if ((getuid() != ru->pw_uid) || (geteuid() != eu->pw_uid)) { - tst_resm(TINFO, "ERROR: %s real uid = %d; effective uid = %d", + tst_resm(TFAIL, "ERROR: %s real uid = %d; effective uid = %d", when, getuid(), geteuid()); tst_resm(TINFO, "Expected: real uid = %d; effective uid = %d", ru->pw_uid, eu->pw_uid); diff --git a/testcases/kernel/syscalls/setreuid/setreuid04.c b/testcases/kernel/syscalls/setreuid/setreuid04.c index 0396f05..3010fc5 100644 --- a/testcases/kernel/syscalls/setreuid/setreuid04.c +++ b/testcases/kernel/syscalls/setreuid/setreuid04.c @@ -1,83 +1,45 @@ /* + * Copyright (c) International Business Machines Corp., 2001 * - * Copyright (c) International Business Machines Corp., 2001 + * This program is free software; you can redistribute it and/or m... [truncated message content] |
From: Cyril H. <su...@li...> - 2013-10-21 11:51:11
|
The branch, master, has been updated via 1e5da030e9cdeb431d41e7eb84658d9c4a5b67e3 (commit) from ba7e78a20a5eb6ab2887c6297d69611bd12c8be2 (commit) - Log ----------------------------------------------------------------- commit 1e5da030e9cdeb431d41e7eb84658d9c4a5b67e3 Author: Stanislav Kholmanskikh <sta...@or...> Date: Thu Oct 17 13:17:03 2013 +0400 memcg_control: revert memory.use_hierarchy value to 0 Documentation/cgroups/memory.txt states that "Enabling/disabling will fail if either the cgroup already has other cgroups created below it, or if the parent cgroup has use_hierarchy enabled." memcg_control_test.sh sets global memory.use_hierarchy value to 1 before the execution of its own tests but doesn't revert it back to 0 after they complete. It causes failures of memcg_stat_test.sh and memcg_use_hierarchy_test.sh testcases if runtest/controllers is run twice on the same host. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> ----------------------------------------------------------------------- Summary of changes: .../memcg/control/memcg_control_test.sh | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh index dfc1302..fa50516 100644 --- a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh +++ b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh @@ -146,6 +146,8 @@ while [ $TST_NUM -le $TST_TOTAL ]; do : $((TST_NUM += 1)) done +echo 0 > mnt/memory.use_hierarchy 2> /dev/null + cleanup if [ "$FAILED_CNT" -ne 0 ]; then hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-21 07:51:09
|
The branch, master, has been updated via ba7e78a20a5eb6ab2887c6297d69611bd12c8be2 (commit) from c793aee5f06b46bdc8171814df71df3c90d47c7d (commit) - Log ----------------------------------------------------------------- commit ba7e78a20a5eb6ab2887c6297d69611bd12c8be2 Author: Maxim Uvarov <max...@li...> Date: Fri Oct 4 14:17:11 2013 +0400 max_map_count: filter out not accounted vector stub for arm Arm has following vector stub: ffff0000-ffff1000 r-xp 00000000 00:00 0 [vectors] which is not accounted in map_count. There are 8 vector regions on arm, only this one is not accounted. Signed-off-by: Maxim Uvarov <max...@li...> Signed-off-by: Jan Stancek <jst...@re...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/mem/tunable/max_map_count.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/testcases/kernel/mem/tunable/max_map_count.c b/testcases/kernel/mem/tunable/max_map_count.c index 01fbe5e..ca28fba 100644 --- a/testcases/kernel/mem/tunable/max_map_count.c +++ b/testcases/kernel/mem/tunable/max_map_count.c @@ -121,12 +121,24 @@ void cleanup(void) * for in the vm_area_struct's map_count. */ #if defined(__x86_64__) || defined(__x86__) -static int filter_map(char *buf) +static int filter_map(char *line) { + char buf[BUFSIZ]; + int ret; + + ret = sscanf(line, "%*p-%*p %*4s %*p %*2d:%*2d %*d %s", buf); + if (ret != 1) + return 0; + return strcmp(buf, "[vsyscall]") == 0; } +#elif defined(__arm__) +static int filter_map(char *line) +{ + return strncmp(line, "ffff0000-ffff1000", 17) == 0; +} #else -static int filter_map(char *buf) +static int filter_map(char *line) { return 0; } @@ -146,8 +158,7 @@ static long count_maps(pid_t pid) tst_brkm(TBROK | TERRNO, cleanup, "fopen %s", buf); while (getline(&line, &len, fp) != -1) { /* exclude vdso and vsyscall */ - if (sscanf(line, "%*p-%*p %*4s %*p %*2d:%*2d %*d %s", buf) == - 1 && filter_map(buf)) + if (filter_map(line)) continue; map_count++; } hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-17 12:51:11
|
The branch, master, has been updated via c793aee5f06b46bdc8171814df71df3c90d47c7d (commit) via 08dcfbb5a4ebad9319c54935a600ab936708c6da (commit) via 7fab4c4d439c9ed108d70c663e50cf4bd99f4254 (commit) via 8bd901edaac6ce1b4edaef835e46b30bec495aee (commit) via d266efb30fd17c290de5bbdf55afcfbbcce3315a (commit) via 836c1f2982c2b1f17a0925987b36565327371ed9 (commit) via 9d466859928d3b811032d0cfd9eea99677f9942a (commit) via e44edbaf213f3e3a5499aa123f86e60e633617a1 (commit) from 8e0f8b158aa3015bfccc6e1b16dd2baee5d03e45 (commit) - Log ----------------------------------------------------------------- commit c793aee5f06b46bdc8171814df71df3c90d47c7d Author: Cyril Hrubis <ch...@su...> Date: Thu Oct 17 12:46:33 2013 +0200 controllers/cpuset: Fix cleanup. On some systems (found on SLES10) cpuset mounts aren't listed in the output from mount (they are not in /etc/mtab at all), so we switch to the /proc/mounts instead. Also fix a race in the loop that kills processes that are left in the currently mounted cpuset. The problem is that if you kill a LTP test, the cleanup is still executed and the test takes some time to finish which results in EBUSY in the umount that is executed right after the loop. The fix is to kill the processes with -9 (SIGKILL) which makes them exit immediately. Signed-off-by: Cyril Hrubis <ch...@su...> commit 08dcfbb5a4ebad9319c54935a600ab936708c6da Author: Cyril Hrubis <ch...@su...> Date: Thu Oct 17 12:20:16 2013 +0200 controllers/cpuset: Fix check for root. The $USER == root check may fail (for example if you did su and the user stayed set to whatever was there before). Moreover rest of the LTP uses euid == 0 to check if you have root privileges, so let's stick to it. Signed-off-by: Cyril Hrubis <ch...@su...> commit 7fab4c4d439c9ed108d70c663e50cf4bd99f4254 Author: Cyril Hrubis <ch...@su...> Date: Thu Oct 17 12:18:53 2013 +0200 controllers/cpuset: Remove unused file. Remove unused copy of cpuset_funcs.sh from the cpuset_lib directory. Signed-off-by: Cyril Hrubis <ch...@su...> commit 8bd901edaac6ce1b4edaef835e46b30bec495aee Author: Stanislav Kholmanskikh <sta...@or...> Date: Fri Oct 4 14:09:02 2013 +0400 cpuset_base_ops_test: using tst_kvercmp2 RHEL6 kernel backported a fix to not produce an error in case of writing '0-' to cpuset/N/{cpus,mems} file. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit d266efb30fd17c290de5bbdf55afcfbbcce3315a Author: Stanislav Kholmanskikh <sta...@or...> Date: Fri Oct 4 14:09:01 2013 +0400 controllers/cpuset: required number of nodes Initially these testcases required a host with 4 CPUs and 3 memory nodes minumum. This prevented to run the testcases on widely used 2-memory-nodes configuration. And in fact the testcases only need 2 memory nodes, and a few needs 4 CPUs. Modified the checks accordingly. Now "ideal" minumum configuration of a host is 4 CPUs and 2 memory nodes. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit 836c1f2982c2b1f17a0925987b36565327371ed9 Author: Stanislav Kholmanskikh <sta...@or...> Date: Fri Oct 4 14:09:00 2013 +0400 controllers/cpuset: fix for old grep It seems that '\s' does not work with old version of grep (2.6.3). Therefore several testcases fail on some distributions using this version. For example - RHEL5-based. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit 9d466859928d3b811032d0cfd9eea99677f9942a Author: Stanislav Kholmanskikh <sta...@or...> Date: Fri Oct 4 14:08:59 2013 +0400 controllers/cpuset: removed './' next to binaries In the testcases removed './' next to binaries. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit e44edbaf213f3e3a5499aa123f86e60e633617a1 Author: Stanislav Kholmanskikh <sta...@or...> Date: Fri Oct 4 14:08:58 2013 +0400 controllers/cpuset: reorganization A separate name is assigned to each cpuset shell testcase (which was invoked earlier by run_cpuset_test.sh). This will simplify results analysis. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> ----------------------------------------------------------------------- Summary of changes: runtest/controllers | 13 + .../cpuset_base_ops_testset.sh | 26 ++- .../cpuset_exclusive_test/cpuset_exclusive_test.sh | 8 +- .../kernel/controllers/cpuset/cpuset_funcs.sh | 46 ++-- .../cpuset_hierarchy_test/cpuset_hierarchy_test.sh | 8 +- .../cpuset_hotplug_test/cpuset_hotplug_test.sh | 14 +- .../cpuset_inherit_test/cpuset_inherit_testset.sh | 8 +- .../controllers/cpuset/cpuset_lib/cpuset_funcs.sh | 265 -------------------- .../cpuset_load_balance_test.sh | 13 +- .../cpuset_sched_domains_test.sh | 15 +- .../cpuset_memory_pressure_testset.sh | 18 +- .../cpuset_memory_spread_testset.sh | 19 +- .../cpuset_memory_test/cpuset_memory_testset.sh | 45 ++-- .../cpuset_syscall_test/cpuset_syscall_testset.sh | 30 ++- .../kernel/controllers/cpuset/run_cpuset_test.sh | 183 -------------- testcases/kernel/controllers/test_controllers.sh | 20 -- 16 files changed, 149 insertions(+), 582 deletions(-) delete mode 100755 testcases/kernel/controllers/cpuset/cpuset_lib/cpuset_funcs.sh delete mode 100755 testcases/kernel/controllers/cpuset/run_cpuset_test.sh diff --git a/runtest/controllers b/runtest/controllers index 94fc185..81a9a10 100644 --- a/runtest/controllers +++ b/runtest/controllers @@ -12,4 +12,17 @@ memcg_stress memcg_stress_test.sh memcg_control PAGESIZE=$(mem_process -p);memcg_control_test.sh $PAGESIZE $PAGESIZE $((PAGESIZE * 2)) cgroup_fj run_cgroup_test_fj.sh controllers test_controllers.sh + +cpuset_base_ops cpuset_base_ops_testset.sh +cpuset_inherit cpuset_inherit_testset.sh +cpuset_exclusive cpuset_exclusive_test.sh +cpuset_hierarchy cpuset_hierarchy_test.sh +cpuset_syscall cpuset_syscall_testset.sh +cpuset_sched_domains cpuset_sched_domains_test.sh +cpuset_load_balance cpuset_load_balance_test.sh +cpuset_hotplug cpuset_hotplug_test.sh +cpuset_memory cpuset_memory_testset.sh +cpuset_memory_pressure cpuset_memory_pressure_testset.sh +cpuset_memory_spread cpuset_memory_spread_testset.sh + cgroup_xattr cgroup_xattr diff --git a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh index 126eec5..63a9dc5 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh @@ -22,13 +22,13 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset01" +export TCID="cpuset_base_ops" export TST_TOTAL=97 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check nr_cpus=$NR_CPUS nr_mems=$N_NODES @@ -118,14 +118,17 @@ test_cpus() -1 WRITE_ERROR 0-$nr_cpus WRITE_ERROR 0--$((nr_cpus-1)) WRITE_ERROR - 0,1-$((nr_cpus-2)),$((nr_cpus-1)) 0-$((nr_cpus-1)) - 0,1-$((nr_cpus-2)), 0-$((nr_cpus-2)) 0AAA WRITE_ERROR AAA WRITE_ERROR EOF # while read cpus result - tst_kvercmp 3 0 0 + if [ $nr_cpus -ge 3 ]; then + base_op_test "$CPUSET/1/cpus" "0,1-$((nr_cpus-2)),$((nr_cpus-1))" "0-$((nr_cpus-1))" + base_op_test "$CPUSET/1/cpus" "0,1-$((nr_cpus-2))," "0-$((nr_cpus-2))" + fi + + tst_kvercmp2 3 0 0 "RHEL6:2.6.32" if [ $? -eq 0 ]; then base_op_test "$CPUSET/1/cpus" "0-" "WRITE_ERROR" else @@ -151,14 +154,17 @@ test_mems() -1 WRITE_ERROR 0-$nr_mems WRITE_ERROR 0--$((nr_mems-1)) WRITE_ERROR - 0,1-$((nr_mems-2)),$((nr_mems-1)) 0-$((nr_mems-1)) - 0,1-$((nr_mems-2)), 0-$((nr_mems-2)) 0AAA WRITE_ERROR AAA WRITE_ERROR EOF # while read mems result - tst_kvercmp 3 0 0 + if [ $nr_mems -ge 3 ]; then + base_op_test "$CPUSET/1/mems" "0,1-$((nr_mems-2)),$((nr_mems-1))" "0-$((nr_mems-1))" + base_op_test "$CPUSET/1/mems" "0,1-$((nr_mems-2))," "0-$((nr_mems-2))" + fi + + tst_kvercmp2 3 0 0 "RHEL6:2.6.32" if [ $? -eq 0 ]; then base_op_test "$CPUSET/1/mems" "0-" "WRITE_ERROR" else diff --git a/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh b/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh index 0ad31e7..2188ab6 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh @@ -22,13 +22,13 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset03" +export TCID="cpuset_exclusive" export TST_TOTAL=18 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check exit_status=0 diff --git a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh index a83845c..79ecdad 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh @@ -65,23 +65,23 @@ version_check() ncpus_check() { - if [ $NR_CPUS -lt 4 ]; then - tst_brkm TCONF ignored "The total of CPUs is less than 4" + if [ $NR_CPUS -lt $1 ]; then + tst_brkm TCONF ignored "The total of CPUs is less than $1" return 1 fi } nnodes_check() { - if [ $N_NODES -lt 3 ]; then - tst_brkm TCONF ignored "The total of nodes is less than 3" + if [ $N_NODES -lt $1 ]; then + tst_brkm TCONF ignored "The total of nodes is less than $1" return 1 fi } user_check() { - if [ "$USER" != root ]; then + if [ $(id -u) != 0 ]; then tst_brkm TCONF ignored "Test must be run as root" return 1 fi @@ -89,38 +89,48 @@ user_check() cpuset_check() { - grep cpuset /proc/cgroups > /dev/null 2>&1 - if [ $? -ne 0 ]; then - tst_brkm TCONF ignored "Cpuset is not supported" - return 1 + if [ -f /proc/cgroups ]; then + CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1` + CPUSET_CONTROLLER_VALUE=`grep -w cpuset /proc/cgroups | cut -f4` + + if [ "$CPUSET_CONTROLLER" = "cpuset" ] && [ "$CPUSET_CONTROLLER_VALUE" = "1" ] + then + return 0 + fi fi + + tst_brkm TCONF ignored "Cpuset is not supported" + return 1 } +# optional parameters (pass both or none of them): +# $1 - required number of cpus (default 2) +# $2 - required number of memory nodes (default 2) check() { user_check if [ $? -ne 0 ]; then - return 1 + exit 0 fi cpuset_check if [ $? -ne 0 ]; then - return 1 + exit 0 fi version_check if [ $? -ne 0 ]; then - return 1 + exit 0 fi - ncpus_check + ncpus_check ${1:-2} if [ $? -ne 0 ]; then - return 1 + exit 0 fi - nnodes_check + nnodes_check ${2:-2} if [ $? -ne 0 ]; then - return 1 + exit 0 fi } @@ -152,7 +162,7 @@ setup() # Write the cleanup function cleanup() { - mount | grep "$CPUSET" >/dev/null 2>&1 || { + grep "$CPUSET" /proc/mounts >/dev/null 2>&1 || { rm -rf "$CPUSET" >/dev/null 2>&1 return 0 } @@ -161,7 +171,7 @@ cleanup() do while read pid do - /bin/kill $pid > /dev/null 2>&1 + /bin/kill -9 $pid > /dev/null 2>&1 if [ $? -ne 0 ]; then tst_brkm TFAIL ignored "Couldn't kill task - "\ "$pid in the cpuset" diff --git a/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh b/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh index 5804aa4..61f58fc 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh @@ -22,13 +22,13 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset04" +export TCID="cpuset_hierarchy" export TST_TOTAL=32 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check nr_cpus=$NR_CPUS nr_mems=$N_NODES diff --git a/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh b/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh index 2bfe0f5..611ea62 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh @@ -22,13 +22,13 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset08" +export TCID="cpuset_hotplug" export TST_TOTAL=13 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check exit_status=0 @@ -36,7 +36,7 @@ nr_cpus=$NR_CPUS nr_mems=$N_NODES cpus_all="$(seq -s, 0 $((nr_cpus-1)))" -cpus_all="`./cpuset_list_compute $cpus_all`" +cpus_all="`cpuset_list_compute $cpus_all`" mems_all="$(seq -s, 0 $((nr_mems-1)))" # check_result <result> <expect> @@ -224,7 +224,7 @@ base_test() # Test Case 1-2 test_root_cpu_hotplug() { - local tmp_cpus="`./cpuset_list_compute -s $cpus_all $HOTPLUG_CPU`" + local tmp_cpus="`cpuset_list_compute -s $cpus_all $HOTPLUG_CPU`" test_function="root_cpu_hotplug_test" while read hotplug cpus_expect task_expect @@ -240,7 +240,7 @@ test_root_cpu_hotplug() # Test Case 3-6 test_general_cpu_hotplug() { - local tmp_cpus="`./cpuset_list_compute -s $cpus_all $HOTPLUG_CPU`" + local tmp_cpus="`cpuset_list_compute -s $cpus_all $HOTPLUG_CPU`" test_function="general_cpu_hotplug_test" while read hotplug cpus cpus_expect task_expect diff --git a/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh index 780b7eb..f9d524e 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh @@ -22,13 +22,13 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset02" +export TCID="cpuset_inherit" export TST_TOTAL=27 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check nr_cpus=$NR_CPUS nr_mems=$N_NODES diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/cpuset_funcs.sh b/testcases/kernel/controllers/cpuset/cpuset_lib/cpuset_funcs.sh deleted file mode 100755 index b996461..0000000 --- a/testcases/kernel/controllers/cpuset/cpuset_lib/cpuset_funcs.sh +++ /dev/null @@ -1,265 +0,0 @@ -#!/bin/sh -# usage: . cpuset_funcs.sh -# functions for cpuset test - -################################################################################ -## ## -## Copyright (c) 2009 FUJITSU LIMITED ## -## ## -## This program is free software; you can redistribute it and#or modify ## -## it under the terms of the GNU General Public License as published by ## -## the Free Software Foundation; either version 2 of the License, or ## -## (at your option) any later version. ## -## ## -## This program is distributed in the hope that it will be useful, but ## -## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## -## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## -## for more details. ## -## ## -## You should have received a copy of the GNU General Public License ## -## along with this program; if not, write to the Free Software ## -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## -## ## -## Author: Miao Xie <mi...@cn...> ## -## ## -################################################################################ - -NR_CPUS=`tst_ncpus` -if [ -f "/sys/devices/system/node/has_high_memory" ]; then - N_NODES="`cat /sys/devices/system/node/has_high_memory`" -else - N_NODES="`cat /sys/devices/system/node/has_normal_memory`" -fi -N_NODES=${N_NODES#*-*} -: $((N_NODES++)) - -CPUSET="/dev/cpuset" -CPUSET_TMP="/tmp/cpuset_tmp" - -HOTPLUG_CPU="1" - -cpuset_log() -{ - tst_resm TINFO "$*" -} - -# cpuset_log_error <error_file> -cpuset_log_error() -{ - local error_message= - - while read error_message - do - cpuset_log "$error_message" - done < "$1" -} - -version_check() -{ - tst_kvercmp 2 6 28 - if [ $? -eq 0 ]; then - tst_brkm TCONF ignored "kernel is below 2.6.28" - return 1 - fi -} - -ncpus_check() -{ - if [ $NR_CPUS -lt 4 ]; then - tst_brkm TCONF ignored "The total of CPUs is less than 4" - return 1 - fi -} - -nnodes_check() -{ - if [ $N_NODES -lt 3 ]; then - tst_brkm TCONF ignored "The total of nodes is less than 3" - return 1 - fi -} - -user_check() -{ - if [ "$USER" != root ]; then - tst_brkm TCONF ignored "Test must be run as root" - return 1 - fi -} - -cpuset_check() -{ - grep cpuset /proc/cgroups > /dev/null 2>&1 - if [ $? -ne 0 ]; then - tst_brkm TCONF ignored "Cpuset is not supported" - return 1 - fi -} - -check() -{ - user_check - if [ $? -ne 0 ]; then - return 1 - fi - - cpuset_check - if [ $? -ne 0 ]; then - return 1 - fi - - version_check - if [ $? -ne 0 ]; then - return 1 - fi - - ncpus_check - if [ $? -ne 0 ]; then - return 1 - fi - - nnodes_check - if [ $? -ne 0 ]; then - return 1 - fi - -} - -# Create /dev/cpuset & mount the cgroup file system with cpuset -# clean any group created eralier (if any) -setup() -{ - if [ -e "$CPUSET" ] - then - tst_resm TWARN "$CPUSET already exist.. overwriting" - cleanup || { - tst_brkm TFAIL ignored "Can't cleanup... Exiting" - return 1 - } - fi - - mkdir -p "$CPUSET_TMP" - mkdir "$CPUSET" - mount -t cpuset cpuset "$CPUSET" 2> /dev/null - if [ $? -ne 0 ]; then - tst_brkm TFAIL ignored "Could not mount cgroup filesystem with"\ - " cpuset on $CPUSET..Exiting test" - cleanup - return 1 - fi -} - -# Write the cleanup function -cleanup() -{ - mount | grep "$CPUSET" >/dev/null 2>&1 || { - rm -rf "$CPUSET" >/dev/null 2>&1 - return 0 - } - - find "$CPUSET" -type d | sort | sed -n '2,$p' | tac | while read subdir - do - while read pid - do - /bin/kill $pid > /dev/null 2>&1 - if [ $? -ne 0 ]; then - tst_brkm TFAIL ignored "Couldn't kill task - "\ - "$pid in the cpuset" - return 1 - fi - done < "$subdir/tasks" - rmdir "$subdir" - if [ $? -ne 0 ]; then - tst_brkm TFAIL ignored "Couldn't remove subdir - " - "$subdir in the cpuset" - return 1 - fi - done - - umount "$CPUSET" - if [ $? -ne 0 ]; then - tst_brkm TFAIL ignored "Couldn't umount cgroup filesystem with"\ - " cpuset on $CPUSET..Exiting test" - return 1 - fi - rmdir "$CPUSET" > /dev/null 2>&1 - rm -rf "$CPUSET_TMP" > /dev/null 2>&1 -} - -# set the cpuset's parameter -# cpuset_set <cpusetpath> <cpus> <mems> <load_balance> -cpuset_set() -{ - local path="$1" - mkdir -p "$path" - if [ $? -ne 0 ]; then - return 1 - fi - - local cpus="$2" - local mems="$3" - local load_balance="$4" - - if [ "$path" != "$CPUSET" ]; then - if [ "$cpus" != "-" ]; then - /bin/echo $cpus > $path/cpus - if [ $? -ne 0 ]; then - return 1 - fi - fi - - /bin/echo $mems > $path/mems - if [ $? -ne 0 ]; then - return 1 - fi - fi - - /bin/echo $load_balance > $path/sched_load_balance - if [ $? -ne 0 ]; then - return 1 - fi -} - -# cpu_hotplug cpu_id offline/online -cpu_hotplug() -{ - if [ "$2" = "online" ]; then - /bin/echo 1 > "/sys/devices/system/cpu/cpu$1/online" - if [ $? -ne 0 ]; then - return 1 - fi - elif [ "$2" = "offline" ]; then - /bin/echo 0 > "/sys/devices/system/cpu/cpu$1/online" - if [ $? -ne 0 ]; then - return 1 - fi - fi -} - -# setup_test_environment <online | offline> -# online - online a CPU in testing, so we must offline a CPU first -# offline - offline a CPU in testing, we needn't do anything -setup_test_environment() -{ - if [ "$1" = "online" ]; then - cpu_hotplug $HOTPLUG_CPU offline - if [ $? -ne 0 ]; then - return 1 - fi - fi -} - -cpu_hotplug_cleanup() -{ - local cpus_array="$(seq -s' ' 1 $((NR_CPUS-1)))" - local cpuid= - for cpuid in $cpus_array - do - local file="/sys/devices/system/cpu/cpu$cpuid/online" - local offline="$(cat $file)" - if [ $offline -eq 0 ]; then - cpu_hotplug $cpuid "online" - fi - done -} - diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh index 55f533a..7123019 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh @@ -22,17 +22,16 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset07" +export TCID="cpuset_load_balance" export TST_TOTAL=13 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check 4 2 exit_status=0 -# must >= 3 for: 1-$((nr_mems-2)) nr_cpus=$NR_CPUS nr_mems=$N_NODES @@ -84,7 +83,7 @@ general_load_balance_test1() return 1 fi - ./cpuset_cpu_hog 2> $CPUSET_TMP/cpu-hog_stderr & + cpuset_cpu_hog 2> $CPUSET_TMP/cpu-hog_stderr & pid=$! read fifo < ./myfifo @@ -209,7 +208,7 @@ general_load_balance_test2() return 1 fi - ./cpuset_cpu_hog 2> $CPUSET_TMP/cpu-hog_stderr & + cpuset_cpu_hog 2> $CPUSET_TMP/cpu-hog_stderr & pid=$! # wait for the parent to do prepare diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh index 3ca70df..014bc74 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh @@ -22,17 +22,16 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset06" +export TCID="cpuset_sched_domains" export TST_TOTAL=19 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check 4 2 exit_status=0 -# must >= 3 for: 1-$((nr_mems-2)) nr_cpus=$NR_CPUS nr_mems=$N_NODES @@ -76,7 +75,7 @@ root_load_balance_test() # check sched domains of every CPU sleep 1 - ./cpuset_sched_domains_check 2> $CPUSET_TMP/stderr + cpuset_sched_domains_check 2> $CPUSET_TMP/stderr ret=$? if [ $ret -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr @@ -119,7 +118,7 @@ general_load_balance_test1() # check sched domains of every CPU sleep 1 - ./cpuset_sched_domains_check 2> $CPUSET_TMP/stderr + cpuset_sched_domains_check 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr tst_resm TFAIL "partition sched domains failed." @@ -195,7 +194,7 @@ general_load_balance_test2() # check sched domains of every CPU sleep 1 - ./cpuset_sched_domains_check > $CPUSET_TMP/stdout + cpuset_sched_domains_check > $CPUSET_TMP/stdout if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stdout tst_resm TFAIL "partition sched domains failed." diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh index f342e6c..fcf00d4 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh @@ -22,13 +22,13 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset10" +export TCID="cpuset_memory_pressure" export TST_TOTAL=6 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check exit_status=0 @@ -69,7 +69,7 @@ test2() return 1 fi - ./cpuset_memory_pressure $usemem + cpuset_memory_pressure $usemem local i for i in $(seq 0 9) @@ -135,7 +135,7 @@ test4() return 1 fi - ./cpuset_memory_pressure $usemem + cpuset_memory_pressure $usemem echo $$ > "$CPUSET/tasks" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then @@ -174,7 +174,7 @@ test5() return 1 fi - ./cpuset_memory_pressure $usemem + cpuset_memory_pressure $usemem local i for i in $(seq 0 9) do @@ -211,7 +211,7 @@ test6() tst_resm TFAIL "attaching self to sub group failed" return 1 fi - ./cpuset_memory_pressure $usemem + cpuset_memory_pressure $usemem echo $$ > "$CPUSET/tasks" 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then @@ -220,7 +220,7 @@ test6() return 1 fi - ./cpuset_memory_pressure $usemem + cpuset_memory_pressure $usemem local i for i in $(seq 0 9) do diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh index ffce419..ad989f3 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh @@ -22,16 +22,15 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset11" +export TCID="cpuset_memory_spread" export TST_TOTAL=6 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check exit_status=0 -# must >= 3 for: 1-$((nr_mems-2)) nr_cpus=$NR_CPUS nr_mems=$N_NODES @@ -61,7 +60,7 @@ set_memsinfo_val() local nl=' ' # clearing existent value (if present) - memsinfo=`echo "$memsinfo" | sed -r "/^\_$1\:\s/d"` + memsinfo=`echo "$memsinfo" | sed -r "/^\_$1\: /d"` if [ -z "$memsinfo" ]; then memsinfo="_$1: $2" @@ -74,8 +73,8 @@ set_memsinfo_val() get_memsinfo_val() { local value= - value=`echo "$memsinfo" | grep -e "^\_$1\:\s"` - value=`echo "$value" | sed -r "s/^.*\:\s(.*)$/\1/"` + value=`echo "$memsinfo" | grep -e "^\_$1\: "` + value=`echo "$value" | sed -r "s/^.*\: (.*)$/\1/"` echo "$value" } @@ -256,7 +255,7 @@ base_test() if [ $? -ne 0 ]; then exit_status=1 else - ./cpuset_mem_hog & + cpuset_mem_hog & pid=$! general_memory_spread_test "$@" "$pid" result_num=$? @@ -303,7 +302,7 @@ test_spread_page2() if [ $? -ne 0 ]; then exit_status=1 else - ./cpuset_mem_hog & + cpuset_mem_hog & pid=$! general_memory_spread_test "1" "$cpus_all" "0" "0" "$pid" result_num=$? diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh index 2a9f7e3..e8ef6bf 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh @@ -22,17 +22,16 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset09" +export TCID="cpuset_memory" export TST_TOTAL=18 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check exit_status=0 -# must >= 3 for: 1-$((nr_mems-2)) nr_cpus=$NR_CPUS nr_mems=$N_NODES @@ -71,7 +70,7 @@ test1() return 1 fi - ./cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" if [ "$node" != "0" ]; then tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." @@ -88,7 +87,7 @@ test2() return 1 fi - ./cpuset_memory_test --mmap-file >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-file >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" if [ "$node" != "0" ]; then tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." @@ -105,7 +104,7 @@ test3() return 1 fi - ./cpuset_memory_test --shm >"$MEMORY_RESULT" & + cpuset_memory_test --shm >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" if [ "$node" != "0" ]; then tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." @@ -122,7 +121,7 @@ test4() return 1 fi - ./cpuset_memory_test --mmap-lock1 >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-lock1 >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" if [ "$node" != "0" ]; then tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." @@ -139,7 +138,7 @@ test5() return 1 fi - ./cpuset_memory_test --mmap-lock2 >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-lock2 >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" if [ "$node" != "0" ]; then tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." @@ -182,7 +181,7 @@ test6() save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages) echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages - ./cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" umount /hugetlb @@ -221,7 +220,7 @@ test7() save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages) echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages - ./cpuset_memory_test --shm --hugepage -s $HUGEPAGESIZE --key=7 >"$MEMORY_RESULT" & + cpuset_memory_test --shm --hugepage -s $HUGEPAGESIZE --key=7 >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" umount /hugetlb @@ -248,7 +247,7 @@ test8() return 1 fi - ./cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" if [ "$node" != "0" ]; then tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#0)." @@ -265,7 +264,7 @@ test9() return 1 fi - ./cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" if [ "$node" != "1" ]; then tst_resm TFAIL "allocate memory on the Node#$node(Expect: Node#1)." @@ -308,7 +307,7 @@ test10() return 1 fi - ./cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" & talk2memory_test_for_case_10_11 $! "$CPUSET/1" "$CPUSET/2" { read node0 @@ -353,7 +352,7 @@ test11() return 1 fi - ./cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" & talk2memory_test_for_case_10_11 $! "$CPUSET/1" "$CPUSET/2" { read node0 @@ -405,7 +404,7 @@ test12() return 1 fi - ./cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-anon >"$MEMORY_RESULT" & talk2memory_test_for_case_12_13 $! "$CPUSET/0" { @@ -441,7 +440,7 @@ test13() fi - ./cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" & + cpuset_memory_test --mmap-anon --check >"$MEMORY_RESULT" & talk2memory_test_for_case_12_13 $! "$CPUSET/0" { @@ -496,7 +495,7 @@ test14() return 1 fi - ./cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & + cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & { local testpid=$! sleep 1 @@ -552,7 +551,7 @@ test15() fi - ./cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & + cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & { local testpid=$! sleep 1 @@ -608,7 +607,7 @@ test16() fi - ./cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & + cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & { local testpid=$! sleep 1 @@ -674,7 +673,7 @@ test17() return 1 fi - ./cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & + cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & { local testpid=$! sleep 1 @@ -756,7 +755,7 @@ test18() return 1 fi - ./cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & + cpuset_memory_test --thread --mmap-anon >"$MEMORY_RESULT" & { local testpid=$! sleep 1 diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh index af92373..561c3b9 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh @@ -22,25 +22,27 @@ # # ################################################################################ -cd $LTPROOT/testcases/bin - -export TCID="cpuset05" +export TCID="cpuset_syscall" export TST_TOTAL=16 export TST_COUNT=1 -. ./cpuset_funcs.sh +. cpuset_funcs.sh + +check exit_status=0 +nr_mems=$N_NODES + TEST_CPUSET="$CPUSET/0" TEST_OUTPUT="$CPUSET_TMP/result" TEST_PROCSTATUS="$CPUSET_TMP/status" TEST_PROCNUMA="$CPUSET_TMP/numa_maps" -# do_syscall_test - call ./syscall_test +# do_syscall_test - call syscall_test # $1 - cpus # $2 - mems -# $3 - ./syscall_test's args +# $3 - syscall_test's args # $4 - expect return value of test task do_syscall_test() @@ -63,7 +65,7 @@ do_syscall_test() tst_resm TFAIL "set $TEST_CPUSET/mems as $2 fail." return 1 fi - ./cpuset_syscall_test $3 >"$TEST_OUTPUT" & + cpuset_syscall_test $3 >"$TEST_OUTPUT" & testpid=$! echo $testpid > "$TEST_CPUSET/tasks" if [ $? -ne 0 ]; then @@ -231,7 +233,7 @@ test10() awk '{print $2}') allowed_list="$(echo $allowed_list | sed -e s/bind://)" - task_policy=$(cat $TEST_PROCNUMA | grep -e "\s\+stack\s\+anon" | \ + task_policy=$(cat $TEST_PROCNUMA | grep -e " *stack *anon" | \ awk '{print $2}') test "$allowed_list" = "$task_policy" @@ -276,14 +278,22 @@ test12() test13() { - do_syscall_test 0 0-1 --set_mempolicy=6 0 || return 1 + if [ $nr_mems -ge 3 ]; then + do_syscall_test 0 0-1 --set_mempolicy=6 0 || return 1 + else + do_syscall_test 0 0-1 --set_mempolicy=2 0 || return 1 + fi check_result "1" return $? } test14() { - do_syscall_test 0 0 --set_mempolicy=6 1 || return 1 + if [ $nr_mems -ge 3 ]; then + do_syscall_test 0 0 --set_mempolicy=6 1 || return 1 + else + do_syscall_test 0 0 --set_mempolicy=2 1 || return 1 + fi return 0 } diff --git a/testcases/kernel/controllers/cpuset/run_cpuset_test.sh b/testcases/kernel/controllers/cpuset/run_cpuset_test.sh deleted file mode 100755 index abdc885..0000000 --- a/testcases/kernel/controllers/cpuset/run_cpuset_test.sh +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/sh -# usage ./run_cpuset_test.sh test_num - -################################################################################ -# # -# Copyright (c) 2009 FUJITSU LIMITED # -# # -# This program is free software; you can redistribute it and#or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation; either version 2 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, but # -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # -# for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program; if not, write to the Free Software # -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # -# # -################################################################################ -# Name Of File: run_cpuset_test.sh # -# # -# Description: This file runs the setup for testing different cpuset resource # -# controller features. After setup it runs diff test cases in # -# diff setup. # -# # -# Test 01: Tests basal operation of control file # -# # -# Precaution: Avoid system use by other applications/users to get fair and # -# appropriate results (avoid unnecessary killing of applicatio) # -# # -# Author: Miao Xie <mi...@cn...> # -# # -# History: # -# # -# DATE NAME EMAIL DESC # -# # -# 02/03/09 Miao Xie <mi...@cn...> Created this test # -# # -################################################################################ - -export TCID="cpuset_test"; -export TST_TOTAL=1; -export TST_COUNT=1; - -. cpuset_funcs.sh; - -TEST_NUM=$1; -SCRIPT_PID=$$; -RC=0; -PWD=`pwd`; - -check -if [ $? -ne 0 ]; then - exit 0 -fi - -# The usage of the script file -usage() -{ - echo "Could not start cpuset controller test"; - echo "usage: run_cpuset_test.sh test_num"; - echo "Skipping the cpuset controller test..."; -} - -cd $LTPROOT/testcases/bin/ - -echo "TEST $TEST_NUM: CPUSET CONTROLLER TESTING"; - -echo "TEST STARTED: Please avoid using system while this test executes"; -#Check if C source file has been compiled and then run it in different groups - -case $TEST_NUM in -"1" ) - if [ -f cpuset_base_ops_testset.sh ]; then - ./cpuset_base_ops_testset.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"2" ) - if [ -f cpuset_inherit_testset.sh ]; then - ./cpuset_inherit_testset.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"3" ) - if [ -f cpuset_exclusive_test.sh ]; then - ./cpuset_exclusive_test.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"4" ) - if [ -f cpuset_hierarchy_test.sh ]; then - ./cpuset_hierarchy_test.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"5" ) - if [ -f cpuset_syscall_testset.sh ]; then - ./cpuset_syscall_testset.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"6" ) - if [ -f cpuset_sched_domains_test.sh ]; then - ./cpuset_sched_domains_test.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"7" ) - if [ -f cpuset_load_balance_test.sh ]; then - ./cpuset_load_balance_test.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"8" ) - if [ -f cpuset_hotplug_test.sh ]; then - ./cpuset_hotplug_test.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"9" ) - if [ -f cpuset_memory_testset.sh ]; then - ./cpuset_memory_testset.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"10" ) - if [ -f cpuset_memory_pressure_testset.sh ]; then - ./cpuset_memory_pressure_testset.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"11" ) - if [ -f cpuset_memory_spread_testset.sh ]; then - ./cpuset_memory_spread_testset.sh - exit $?; - else - echo "Shell file not installed..Please check Makefile...Exiting" - exit -1; - fi; - ;; -"*" ) - usage; - exit -1; - ;; -esac - -echo "Cpuset Resource Controller test executed successfully."; -cd $PWD -exit 0; #to let PAN reprt success of test diff --git a/testcases/kernel/controllers/test_controllers.sh b/testcases/kernel/controllers/test_controllers.sh index d3c3362..7aa974f 100755 --- a/testcases/kernel/controllers/test_controllers.sh +++ b/testcases/kernel/controllers/test_controllers.sh @@ -47,8 +47,6 @@ then IOTHROTTLE_CONTROLLER_VALUE=`grep -w blockio /proc/cgroups | cut -f4`; FREEZER=`grep -w freezer /proc/cgroups | cut -f1`; FREEZER_VALUE=`grep -w freezer /proc/cgroups | cut -f4`; - CPUSET_CONTROLLER=`grep -w cpuset /proc/cgroups | cut -f1` - CPUSET_CONTROLLER_VALUE=`grep -w cpuset /proc/cgroups | cut -f4` CPUACCOUNT_CONTROLLER=`grep -w cpuacct /proc/cgroups | cut -f1` CPUACCOUNT_CONTROLLER_VALUE=`grep -w cpuacct /proc/cgroups | cut -f4` @@ -102,24 +100,6 @@ then echo "Kernel does not support freezer controller"; echo "Skipping all freezer testcases...."; fi - if [ "$CPUSET_CONTROLLER" = "cpuset" ] && [ "$CPUSET_CONTROLLER_VALUE" = "1" ] - then - $LTPROOT/testcases/bin/run_cpuset_test.sh 1; - $LTPROOT/testcases/bin/run_cpuset_test.sh 2; - $LTPROOT/testcases/bin/run_cpuset_test.sh 3; - $LTPROOT/testcases/bin/run_cpuset_test.sh 4; - $LTPROOT/testcases/bin/run_cpuset_test.sh 5; - $LTPROOT/testcases/bin/run_cpuset_test.sh 6; - $LTPROOT/testcases/bin/run_cpuset_test.sh 7; - $LTPROOT/testcases/bin/run_cpuset_test.sh 8; - $LTPROOT/testcases/bin/run_cpuset_test.sh 9; - $LTPROOT/testcases/bin/run_cpuset_test.sh 10; - $LTPROOT/testcases/bin/run_cpuset_test.sh 11; - else - echo "CONTROLLERS TESTCASES: WARNING"; - echo "Either Kernel does not support for cpuset controller or functionality is not enabled"; - echo "Skipping all cpuset controller testcases...."; - fi if [ "$CPUACCOUNT_CONTROLLER" = "cpuacct" ] && [ "$CPUACCOUNT_CONTROLLER_VALUE" = "1" ] then $LTPROOT/testcases/bin/run_cpuacct_test.sh 1; hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-17 10:51:12
|
The branch, master, has been updated via 8e0f8b158aa3015bfccc6e1b16dd2baee5d03e45 (commit) from efddf81c171823091af8777b22e6386abc05a7ee (commit) - Log ----------------------------------------------------------------- commit 8e0f8b158aa3015bfccc6e1b16dd2baee5d03e45 Author: Monson Shao <js...@re...> Date: Thu Oct 17 17:26:45 2013 +0800 setns: add ns_name in TINFO Make it clear which namespace is enabled and being tested. before: setns01 0 TINFO : ns_fds[0]=5, ns_types[0]=0x8000000 setns01 0 TINFO : ns_fds[1]=6, ns_types[1]=0x20000 setns01 0 TINFO : ns_fds[2]=7, ns_types[2]=0x40000000 setns01 0 TINFO : ns_fds[3]=8, ns_types[3]=0x20000000 setns01 0 TINFO : ns_fds[4]=9, ns_types[4]=0x4000000 after: setns01 0 TINFO : ns_name=ipc, ns_fds[0]=5, ns_types[0]=0x8000000 setns01 0 TINFO : ns_name=mnt, ns_fds[1]=6, ns_types[1]=0x20000 setns01 0 TINFO : ns_name=net, ns_fds[2]=7, ns_types[2]=0x40000000 setns01 0 TINFO : ns_name=pid, ns_fds[3]=8, ns_types[3]=0x20000000 setns01 0 TINFO : ns_name=uts, ns_fds[4]=9, ns_types[4]=0x4000000 Signed-off-by: Monson Shao <js...@re...> Reviewed-by: Jan Stancek <jst...@re...> Reviewed-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/setns/setns.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/syscalls/setns/setns.h b/testcases/kernel/syscalls/setns/setns.h index 23bdb2e..a05e673 100644 --- a/testcases/kernel/syscalls/setns/setns.h +++ b/testcases/kernel/syscalls/setns/setns.h @@ -53,8 +53,8 @@ static void init_ns_type(int clone_type, const char *proc_name) if (fd != -1) { ns_types[ns_total] = clone_type; ns_fds[ns_total] = fd; - tst_resm(TINFO, "ns_fds[%d]=%d, ns_types[%d]=0x%x", ns_total, - fd, ns_total, clone_type); + tst_resm(TINFO, "ns_name=%s, ns_fds[%d]=%d, ns_types[%d]=0x%x", + proc_name, ns_total, fd, ns_total, clone_type); ns_total++; } } hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-17 08:51:17
|
The branch, master, has been updated via efddf81c171823091af8777b22e6386abc05a7ee (commit) via a2b2b352c9af90c27b58a5e6bcc4dfb8022f3b1a (commit) via 683835e0b151b3d0b7998cc15f0e615820b6d07f (commit) from 48d49bb21eaa84b554938054df77807241d5ed5b (commit) - Log ----------------------------------------------------------------- commit efddf81c171823091af8777b22e6386abc05a7ee Author: Jan Stancek <jst...@re...> Date: Thu Oct 3 10:22:50 2013 +0200 pthread_attr_setschedpolicy/2-1.c: bind threads to single CPU To make sure that threads are blocked on mutex, bind all to single CPU. Because they all use SCHED_FIFO policy with main thread having the lowest priority, main will progress only after three created threads block on mutex. Signed-off-by: Jan Stancek <jst...@re...> commit a2b2b352c9af90c27b58a5e6bcc4dfb8022f3b1a Author: Jan Stancek <jst...@re...> Date: Thu Oct 3 10:10:30 2013 +0200 pthread_attr_setschedpolicy/2-1.c: fix race at thread startup Test can hang during startup in following scenario: main new thread --------------------------------------------------+------------------------------------- int create_thread(int prio, pthread_t * tid) | ... | pthread_create(tid, &attr, thread_func, NULL);| while (!thread_started) { | | void *thread_func(void *data) | thread_started = 1; | pthread_cond_signal(&cond); pthread_mutex_lock(&c_mutex); | 132: pthread_cond_wait(&cond, &c_mutex); | |65: pthread_mutex_lock(&mutex); | (gdb) bt #0 0x00007fd588808f6d in __lll_lock_wait () from /lib64/libpthread.so.0 #1 0x00007fd588804d31 in _L_lock_790 () from /lib64/libpthread.so.0 #2 0x00007fd588804c37 in pthread_mutex_lock () from /lib64/libpthread.so.0 #3 0x0000000000400bba in thread_func (data=0x0) at ../../../conformance/interfaces/pthread_attr_setschedpolicy/2-1.c:65 #4 0x00007fd588802de3 in start_thread () from /lib64/libpthread.so.0 #5 0x00007fd5885300dd in clone () from /lib64/libc.so.6 (gdb) t 2 (gdb) bt #0 0x00007fd5888066f5 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0 #1 0x0000000000400d9b in create_thread (prio=5, tid=0x7fffdb562678) at ../../../conformance/interfaces/pthread_attr_setschedpolicy/2-1.c:132 #2 0x0000000000400e82 in main () at ../../../conformance/interfaces/pthread_attr_setschedpolicy/2-1.c:174 Fix this by using same c_mutex in thread_func for updating thread_started and signalling cond. Signed-off-by: Jan Stancek <jst...@re...> commit 683835e0b151b3d0b7998cc15f0e615820b6d07f Author: Jan Stancek <jst...@re...> Date: Thu Oct 3 10:02:29 2013 +0200 pthread_attr_setschedpolicy/2-1.c: simplify error handling Remove all gotos and if there's error in any of pthread functions exit immediately. Signed-off-by: Jan Stancek <jst...@re...> ----------------------------------------------------------------------- Summary of changes: .../interfaces/pthread_attr_setschedpolicy/2-1.c | 135 +++++++++----------- 1 files changed, 58 insertions(+), 77 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/2-1.c index 6088466..af8e3e4 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/2-1.c @@ -20,17 +20,21 @@ * Date: 20/05/2011 */ +#define _GNU_SOURCE #include <stdio.h> #include <string.h> #include <pthread.h> #include <unistd.h> +#include <stdlib.h> #include <errno.h> #include <posixtest.h> +#include <affinity.h> /* Priorities for the threads, must be unique, non-zero, and ordered */ #define PRIO_HIGH 20 #define PRIO_MED 10 #define PRIO_LOW 5 +#define PRIO_MAIN 1 static int priorities[3]; @@ -40,8 +44,10 @@ static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int thread_started; -#define ERR_MSG(f, rc) printf("Failed: function: %s status: %s(%u)\n", \ - f, strerror(rc), rc) +#define FAIL_AND_EXIT(f, rc) { \ + printf("Failed: function: %s status: %s(%u)\n", f, strerror(rc), rc); \ + exit(PTS_UNRESOLVED); \ +} static void *thread_func(void *data) { @@ -50,23 +56,23 @@ static void *thread_func(void *data) int rc; rc = pthread_getschedparam(pthread_self(), &policy, &sp); - if (rc) { - ERR_MSG("pthread_getschedparam()", rc); - goto done; - } + if (rc) + FAIL_AND_EXIT("pthread_getschedparam()", rc); + rc = pthread_mutex_lock(&c_mutex); + if (rc) + FAIL_AND_EXIT("pthread_mutex_lock()", rc); thread_started = 1; rc = pthread_cond_signal(&cond); - if (rc) { - ERR_MSG("pthread_cond_signal()", rc); - goto done; - } + if (rc) + FAIL_AND_EXIT("pthread_cond_signal()", rc); + rc = pthread_mutex_unlock(&c_mutex); + if (rc) + FAIL_AND_EXIT("pthread_mutex_unlock()", rc); rc = pthread_mutex_lock(&mutex); - if (rc) { - ERR_MSG("pthread_mutex_lock()", rc); - goto done; - } + if (rc) + FAIL_AND_EXIT("pthread_mutex_lock()", rc); /* Stuff the priority in execution order */ if (!priorities[0]) @@ -77,79 +83,56 @@ static void *thread_func(void *data) priorities[2] = sp.sched_priority; rc = pthread_mutex_unlock(&mutex); - if (rc) { - ERR_MSG("pthread_mutex_unlock()", rc); - goto done; - } + if (rc) + FAIL_AND_EXIT("pthread_mutex_unlock()", rc); -done: return (void *)(long)rc; } static int create_thread(int prio, pthread_t * tid) { int rc; - char *func; struct sched_param sp; pthread_attr_t attr; - func = "pthread_attr_init()"; rc = pthread_attr_init(&attr); if (rc != 0) - goto done; + FAIL_AND_EXIT("pthread_attr_init()", rc); - func = "pthread_attr_setschedpolicy()"; rc = pthread_attr_setschedpolicy(&attr, SCHED_FIFO); if (rc != 0) - goto error; + FAIL_AND_EXIT("pthread_attr_setschedpolicy()", rc); - func = "pthread_attr_setinheritsched()"; rc = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); if (rc != 0) - goto error; + FAIL_AND_EXIT("pthread_attr_setinheritsched()", rc); - func = "pthread_attr_setschedparam()"; sp.sched_priority = prio; rc = pthread_attr_setschedparam(&attr, &sp); if (rc != 0) - goto error; + FAIL_AND_EXIT("pthread_attr_setschedparam()", rc); thread_started = 0; rc = pthread_create(tid, &attr, thread_func, NULL); - if (rc) { - ERR_MSG("pthread_create()", rc); - goto error; - } + if (rc) + FAIL_AND_EXIT("pthread_create()", rc); + rc = pthread_mutex_lock(&c_mutex); + if (rc) + FAIL_AND_EXIT("pthread_mutex_lock()", rc); while (!thread_started) { - func = "pthread_mutex_lock()"; - rc = pthread_mutex_lock(&c_mutex); - if (rc) - goto error; - - func = "pthread_cond_wait()"; rc = pthread_cond_wait(&cond, &c_mutex); if (rc) - goto unlock; - - func = "pthread_mutex_unlock()"; - rc = pthread_mutex_unlock(&c_mutex); - if (rc) - goto error; + FAIL_AND_EXIT("pthread_cond_wait()", rc); } + rc = pthread_mutex_unlock(&c_mutex); + if (rc) + FAIL_AND_EXIT("pthread_mutex_unlock()", rc); pthread_attr_destroy(&attr); return 0; - -unlock: - (void)pthread_mutex_unlock(&c_mutex); -error: - pthread_attr_destroy(&attr); -done: - ERR_MSG(func, rc); - return -1; } int main(void) @@ -162,52 +145,51 @@ int main(void) pthread_t t1; pthread_t t2; pthread_t t3; + struct sched_param sp; status = PTS_UNRESOLVED; + + rc = set_affinity(0); + if (rc) + FAIL_AND_EXIT("set_affinity", errno); + + sp.sched_priority = PRIO_MAIN; + rc = pthread_setschedparam(pthread_self(), SCHED_FIFO, &sp); + if (rc) + FAIL_AND_EXIT("pthread_setschedparam()", rc); + rc = pthread_mutex_lock(&mutex); - if (rc) { - ERR_MSG("pthread_mutex_lock()", rc); - goto done; - } + if (rc) + FAIL_AND_EXIT("pthread_mutex_lock()", rc); rc = create_thread(PRIO_LOW, &t3); if (rc) - goto done; + FAIL_AND_EXIT("create_thread LOW", rc); rc = create_thread(PRIO_MED, &t2); if (rc) - goto done; + FAIL_AND_EXIT("create_thread MED", rc); rc = create_thread(PRIO_HIGH, &t1); if (rc) - goto done; + FAIL_AND_EXIT("create_thread HIGH", rc); rc = pthread_mutex_unlock(&mutex); if (rc) - ERR_MSG("pthread_mutex_unlock()", rc); + FAIL_AND_EXIT("pthread_mutex_unlock()", rc); rc = pthread_join(t1, &r1); - if (rc) { - ERR_MSG("pthread_join(t1)", rc); - goto done; - } + if (rc) + FAIL_AND_EXIT("pthread_join(t1)", rc); rc = pthread_join(t2, &r2); - if (rc) { - ERR_MSG("pthread_join(t2)", rc); - goto done; - } + if (rc) + FAIL_AND_EXIT("pthread_join(t2)", rc); rc = pthread_join(t3, &r3); - if (rc) { - ERR_MSG("pthread_join(t3)", rc); - goto done; - } - - /* Threads fail? */ - if ((long)r1 || (long)r2 || (long)r2) - goto done; + if (rc) + FAIL_AND_EXIT("pthread_join(t3)", rc); /* priorities must be high to low */ status = PTS_FAIL; @@ -223,7 +205,6 @@ int main(void) else status = PTS_PASS; -done: if (status == PTS_PASS) printf("Test PASSED\n"); hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-16 14:51:13
|
The branch, master, has been updated via 48d49bb21eaa84b554938054df77807241d5ed5b (commit) from 02c479c2061ad481c7df78a7432bd8cc90027444 (commit) - Log ----------------------------------------------------------------- commit 48d49bb21eaa84b554938054df77807241d5ed5b Author: Alexey Kodanev <ale...@or...> Date: Wed Oct 16 17:24:58 2013 +0400 device-drivers: pci: enable build and run Signed-off-by: Alexey Kodanev <ale...@or...> Acked-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: runtest/kernel_misc | 1 + testcases/kernel/device-drivers/Makefile | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/runtest/kernel_misc b/runtest/kernel_misc index 654e217..db210ec 100644 --- a/runtest/kernel_misc +++ b/runtest/kernel_misc @@ -2,3 +2,4 @@ kmsg01 kmsg01 fw_load fw_load rtc01 rtc01 block_dev block_dev +tpci tpci diff --git a/testcases/kernel/device-drivers/Makefile b/testcases/kernel/device-drivers/Makefile index 73755db..c97d327 100644 --- a/testcases/kernel/device-drivers/Makefile +++ b/testcases/kernel/device-drivers/Makefile @@ -19,6 +19,7 @@ top_srcdir ?= ../../.. include $(top_srcdir)/include/mk/env_pre.mk SUBDIRS := block \ + pci \ rtc \ include $(top_srcdir)/include/mk/generic_trunk_target.mk hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-16 12:51:14
|
The branch, master, has been updated via 02c479c2061ad481c7df78a7432bd8cc90027444 (commit) via 9dcb59183e535430d156d7c2a50ca78969d7485c (commit) from e2ecf28cbbcb99ff5ff576ad0c1ce7145d28bf76 (commit) - Log ----------------------------------------------------------------- commit 02c479c2061ad481c7df78a7432bd8cc90027444 Author: Alexey Kodanev <ale...@or...> Date: Wed Oct 16 14:26:40 2013 +0400 device-drivers: pci: fixes Obsolete code updated to the actual kernel PCI API. Changed test-cases handling from ioctl to sysfs. User-space program rewritten. Signed-off-by: Alexey Kodanev <ale...@or...> Reviewed-by: Cyril Hrubis <ch...@su...> commit 9dcb59183e535430d156d7c2a50ca78969d7485c Author: Alexey Kodanev <ale...@or...> Date: Tue Sep 24 17:37:08 2013 +0400 device-drivers: pci: rename files and remove useless files Signed-off-by: Alexey Kodanev <ale...@or...> Reviewed-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: .../kernel/device-drivers/{block => pci}/Makefile | 0 testcases/kernel/device-drivers/pci/tpci/Makefile | 22 - testcases/kernel/device-drivers/pci/tpci/st_tpci.h | 27 - testcases/kernel/device-drivers/pci/tpci/tpci.c | 893 -------------------- testcases/kernel/device-drivers/pci/tpci/tpci.h | 67 -- .../kernel/device-drivers/pci/tpci/tpci.mod.c | 29 - .../device-drivers/pci/tpci_kernel/.gitignore | 7 + .../kernel/device-drivers/pci/tpci_kernel/Makefile | 35 + .../device-drivers/pci/tpci_kernel/ltp_tpci.c | 787 +++++++++++++++++ .../pci/{tpci => tpci_kernel}/pci-exp-tests-HOWTO | 0 .../kernel/device-drivers/pci/tpci_kernel/tpci.h | 45 + .../kernel/device-drivers/pci/tpci_user/.gitignore | 1 + .../block_dev_user => pci/tpci_user}/Makefile | 0 .../kernel/device-drivers/pci/tpci_user/tpci.c | 120 +++ .../kernel/device-drivers/pci/user_tpci/Makefile | 9 - .../kernel/device-drivers/pci/user_tpci/tpci_ki.c | 198 ----- .../device-drivers/pci/user_tpci/user_tpci.c | 258 ------ .../device-drivers/pci/user_tpci/user_tpci.h | 31 - 18 files changed, 995 insertions(+), 1534 deletions(-) copy testcases/kernel/device-drivers/{block => pci}/Makefile (100%) delete mode 100644 testcases/kernel/device-drivers/pci/tpci/Makefile delete mode 100644 testcases/kernel/device-drivers/pci/tpci/st_tpci.h delete mode 100644 testcases/kernel/device-drivers/pci/tpci/tpci.c delete mode 100644 testcases/kernel/device-drivers/pci/tpci/tpci.h delete mode 100644 testcases/kernel/device-drivers/pci/tpci/tpci.mod.c create mode 100644 testcases/kernel/device-drivers/pci/tpci_kernel/.gitignore create mode 100644 testcases/kernel/device-drivers/pci/tpci_kernel/Makefile create mode 100644 testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c rename testcases/kernel/device-drivers/pci/{tpci => tpci_kernel}/pci-exp-tests-HOWTO (100%) create mode 100644 testcases/kernel/device-drivers/pci/tpci_kernel/tpci.h create mode 100644 testcases/kernel/device-drivers/pci/tpci_user/.gitignore copy testcases/kernel/device-drivers/{block/block_dev_user => pci/tpci_user}/Makefile (100%) create mode 100644 testcases/kernel/device-drivers/pci/tpci_user/tpci.c delete mode 100644 testcases/kernel/device-drivers/pci/user_tpci/Makefile delete mode 100644 testcases/kernel/device-drivers/pci/user_tpci/tpci_ki.c delete mode 100644 testcases/kernel/device-drivers/pci/user_tpci/user_tpci.c delete mode 100644 testcases/kernel/device-drivers/pci/user_tpci/user_tpci.h diff --git a/testcases/kernel/device-drivers/block/Makefile b/testcases/kernel/device-drivers/pci/Makefile similarity index 100% copy from testcases/kernel/device-drivers/block/Makefile copy to testcases/kernel/device-drivers/pci/Makefile diff --git a/testcases/kernel/device-drivers/pci/tpci/Makefile b/testcases/kernel/device-drivers/pci/tpci/Makefile deleted file mode 100644 index 77c80ec..0000000 --- a/testcases/kernel/device-drivers/pci/tpci/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# -# Makefile for GCOV profiling kernel module -# - -#KERNELDIR := /usr/src/linux-2.5.64-gcov -CFLAGS := $(CFLAGS) -Wall - -ifneq ($(KERNELRELEASE),) - -obj-m := tpci.o -else -KDIR := /lib/modules/$(shell uname -r)/build -PWD := $(shell pwd) - -default: - $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules -# $(MAKE) -C $(KERNELDIR) SUBDIRS=$(PWD) modules -endif - -clean: - rm -f tpci.o 2>/dev/null || true - diff --git a/testcases/kernel/device-drivers/pci/tpci/st_tpci.h b/testcases/kernel/device-drivers/pci/tpci/st_tpci.h deleted file mode 100644 index 4538890..0000000 --- a/testcases/kernel/device-drivers/pci/tpci/st_tpci.h +++ /dev/null @@ -1,27 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * -*/ - -struct tpci_user { - struct pci_dev *dev; - struct pci_bus *bus; - struct pci_driver *drv; - uint32_t state[16]; -}; -typedef struct tpci_user tpci_user_t; diff --git a/testcases/kernel/device-drivers/pci/tpci/tpci.c b/testcases/kernel/device-drivers/pci/tpci/tpci.c deleted file mode 100644 index c994c55..0000000 --- a/testcases/kernel/device-drivers/pci/tpci/tpci.c +++ /dev/null @@ -1,893 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - - * This pci and pci-express testing kernel module will allow test calls - * to be driven through various ioctl calls in a - * user space program that has attained the appropriate - * file descriptor for this device. For the functions of - * this module to work correctly there must be a pci / pci-express - * device somewhere in the system. The tests do not need - * a specific device, and the first pci device available - * will be grabbed. - * - * author: Sean Ruyle (sr...@us...) - * date: 5/20/2003 - * PCI-Express test scripts author: Amit Khanna (ami...@in...) - * date: 8/20/2004 - * - * file: tpci.c, - * module: tpci - */ - -#include <linux/config.h> -#include <linux/types.h> -#include <linux/kernel.h> -#include <linux/fs.h> -#include <linux/ioctl.h> -#include <linux/module.h> -#include <linux/init.h> -#include <linux/pci.h> -#include <asm/uaccess.h> -#include "tpci.h" -#include "st_tpci.h" - -MODULE_AUTHOR - ("Sean Ruyle <sr...@us...>, Amit Khanna <ami...@in...>"); -MODULE_DESCRIPTION(TPCI_TEST_DRIVER_NAME); -MODULE_LICENSE("GPL"); - -static int tpci_ioctl(struct inode *, struct file *, unsigned int, - unsigned long); -static int tpci_open(struct inode *, struct file *); -static int tpci_close(struct inode *, struct file *); - -static int probe_pci_dev(void); -static int pci_enable(void); -static int pci_disable(void); -static int test_find_bus(void); -static int test_find_class(void); -static int test_find_device(void); -static int test_find_subsys(void); -static int test_scan_bus(void); -static int test_slot_scan(void); -static int test_bus_add_devices(void); -static int test_enable_bridges(void); -static int test_match_device(void); -static int test_reg_driver(void); -static int test_unreg_driver(void); -static int test_assign_resources(void); -static int test_save_state(void); -static int test_restore_state(void); -static int test_max_bus(void); -static int test_find_cap(void); -static int test_find_pci_exp_cap(void); -static int test_read_pci_exp_config(void); - -static int Major = TPCI_MAJOR; -static tpci_user_t ltp_pci; - -/* - * File operations struct, to use operations find the - * correct file descriptor - */ -static struct file_operations tpci_fops = { -open: tpci_open, -release:tpci_close, -ioctl: tpci_ioctl, -}; - -/* - * open and close operations - */ -static int tpci_open(struct inode *ino, struct file *f) -{ - return 0; -} - -static int tpci_close(struct inode *ino, struct file *f) -{ - return 0; -} - -/* - * tpci_ioctl: - * a user space program can drive the test functions - * through a call to ioctl once the correct file - * descriptor has been attained - * - * calls functions: - * - */ -static int tpci_ioctl(struct inode *ino, struct file *f, - unsigned int cmd, unsigned long l) -{ - int rc; - struct tpci_interface tif; - caddr_t *inparms; - caddr_t *outparms; - - printk("Enter tpci_ioctl\n"); - - inparms = NULL; - outparms = NULL; - rc = 0; - - if (copy_from_user(&tif, (void *)l, sizeof(tif))) { - /* Bad address */ - return (-EFAULT); - } - - /* - * Setup inparms and outparms as needed - */ - if (tif.in_len > 0) { - inparms = (caddr_t *) kmalloc(tif.in_len, GFP_KERNEL); - if (!inparms) { - return (-ENOMEM); - } - - rc = copy_from_user(inparms, tif.in_data, tif.in_len); - if (rc) { - kfree(inparms); - return (-EFAULT); - } - } - if (tif.out_len > 0) { - outparms = (caddr_t *) kmalloc(tif.out_len, GFP_KERNEL); - if (!outparms) { - kfree(inparms); - return (-ENOMEM); - } - } - - /* - * determine which call to make on the cmd value - */ - switch (cmd) { - case PCI_PROBE: - rc = probe_pci_dev(); - break; - case PCI_ENABLE: - rc = pci_enable(); - break; - case PCI_DISABLE: - rc = pci_disable(); - break; - case FIND_BUS: - rc = test_find_bus(); - break; - case FIND_CLASS: - rc = test_find_class(); - break; - case FIND_DEVICE: - rc = test_find_device(); - break; - case FIND_SUBSYS: - rc = test_find_subsys(); - break; - case BUS_SCAN: - rc = test_scan_bus(); - break; - case SLOT_SCAN: - rc = test_slot_scan(); - break; - case BUS_ADD_DEVICES: - rc = test_bus_add_devices(); - break; - case ENABLE_BRIDGES: - rc = test_enable_bridges(); - break; - case MATCH_DEVICE: - rc = test_match_device(); - break; - case REG_DRIVER: - rc = test_reg_driver(); - break; - case UNREG_DRIVER: - rc = test_unreg_driver(); - break; - case PCI_RESOURCES: - rc = test_assign_resources(); - break; - case SAVE_STATE: - rc = test_save_state(); - break; - case RESTORE_STATE: - rc = test_restore_state(); - break; - case TEST_MAX_BUS: - rc = test_max_bus(); - break; - case FIND_CAP: - rc = test_find_cap(); - break; - case FIND_PCI_EXP_CAP: - rc = test_find_pci_exp_cap(); - break; - case READ_PCI_EXP_CONFIG: - rc = test_read_pci_exp_config(); - break; - default: - printk("Mismatching ioctl command\n"); - break; - } - - if (!(ltp_pci.dev)) - printk("tpci: After ioctl call dev is NULL\n"); - - /* - * copy in the return data, and test return code - */ - tif.out_rc = rc; - rc = 0; - - /* if outparms then copy outparms into tif.out_data */ - if (outparms) { - if (copy_to_user(tif.out_data, outparms, tif.out_len)) { - printk("tpci: Unsuccessful copy_to_user of outparms\n"); - rc = -EFAULT; - } - } - - /* copy tif structure into l so that can be used by user program */ - if (copy_to_user((void *)l, &tif, sizeof(tif))) { - printk("tpci: Unsuccessful copy_to_user of tif\n"); - rc = -EFAULT; - } - - /* - * free inparms and outparms - */ - if (inparms) { - kfree(inparms); - } - if (outparms) { - kfree(outparms); - } - - return rc; -} - -/* - * probe_pci_dev - * find a pci device that can be used for other test - * calls in this kernel module, select first device - * that finds for use, do not need a specific device - */ -static int probe_pci_dev() -{ - unsigned int i, j; - struct pci_dev *dev = - (struct pci_dev *)kmalloc(sizeof(struct pci_dev), GFP_KERNEL); - struct pci_bus *bus = - (struct pci_bus *)kmalloc(sizeof(struct pci_bus), GFP_KERNEL); - - /* Zero out the ltp_pci */ - memset(<p_pci, 0, sizeof(tpci_user_t)); - - ltp_pci.dev = dev; - ltp_pci.bus = bus; - - /* Probe until find a pci device */ - for (i = MAX_BUS; i > 0; i--) { - for (j = MAX_DEVFN; j > 1; j--) { - dev = pci_find_slot(i, j); - if (dev && dev->driver) { - printk - ("tpci: found pci_dev, bus %d, devfn %d\n", - i, j); - printk("Slot number: %d\n", dev->devfn); - - bus = dev->bus; - printk("Bus number: %d\n", bus->number); - - /* copy data into ltp_pci struct */ - memcpy(ltp_pci.dev, dev, - sizeof(struct pci_dev)); - memcpy(ltp_pci.bus, bus, - sizeof(struct pci_bus)); - - return 0; - } - } - } - - /* if reaches here did not find a pci device */ - printk("tpci: failed to find pci device\n"); - return 1; -} - -/* - * pci_enable - * enable a pci device so that it may be used in - * later testing in the user test program - */ -static int pci_enable() -{ - int rc = 0; - - struct pci_dev *dev = ltp_pci.dev; - - /* check if can enable the device pointer */ - if (!dev) { - printk("tpci: dev is NULL\n"); - return 1; - } - - if (pci_enable_device(dev)) { - printk("tpci: failed to enable pci device\n"); - rc = 1; - } else { - printk("tpci: enabled pci device\n"); - rc = 0; - } - - return rc; -} - -/* - * pci_disable - * call to pci_disable_device - */ -static int pci_disable() -{ - int rc = 0; - - struct pci_dev *dev = ltp_pci.dev; - - /* check if device pointer exists */ - if (!dev) { - printk("tpci: dev is NULL\n"); - return 1; - } - - pci_disable_device(dev); - - if (dev->current_state == 4 || dev->current_state == 3) { - printk("tpci: disabled pci device\n"); - rc = 0; - } else { - printk("tpci: failed to disable pci device\n"); - rc = 1; - } - - return rc; -} - -/* - * find_bus - * call to pci_find_bus, use values from bus - * pointer in ltp_pci, make sure that returns - * bus with same values - */ -static int test_find_bus() -{ - int rc; - int num = ltp_pci.bus->number; - struct pci_bus *temp = NULL; - - temp = pci_find_bus(num); - - if (!temp) { - printk("tpci: pci_find_bus failed to return bus pointer\n"); - rc = 1; - } else if (temp->number != num) { - printk("tpci: returned bus pointer w/ wrong bus number\n"); - rc = 1; - } else { - printk("tpci: success returned bus pointer \n"); - rc = 0; - } - - return rc; -} - -/* - * find_class - * call to pci_find_class, using values from the - * pci_dev pointer in ltp_pci structure - */ -static int test_find_class() -{ - int rc; - unsigned int num = ltp_pci.dev->class; - struct pci_dev *temp = NULL; - - temp = pci_find_class(num, NULL); - - if (!temp) { - printk("tpci: failed to find pci device from class number\n"); - rc = 1; - } else { - printk("tpci: found pci device from class number\n"); - rc = 0; - } - - return rc; -} - -/* - * find_device - * call to pci_find_device, using values for - * parameters from pci_dev pointer in the - * ltp_pci structure - */ -static int test_find_device() -{ - int rc; - struct pci_dev *temp = NULL; - unsigned short ven = ltp_pci.dev->vendor, dev = ltp_pci.dev->device; - - temp = pci_find_device(ven, dev, NULL); - - if (!temp) { - printk("tpci: failed to find pci device from device info\n"); - rc = 1; - } else { - printk("tpci: found pci device from device info\n"); - rc = 0; - } - - return rc; -} - -/* - * find_subsys - * call to pci_find_subsys, use valued from - * pci_dev pointer in ltp_pci structure to - * find pci_dev from subsys info - */ -static int test_find_subsys() -{ - int rc; - struct pci_dev *temp = NULL; - unsigned short ven = ltp_pci.dev->vendor, - dev = ltp_pci.dev->device, - ss_ven = ltp_pci.dev->subsystem_vendor, - ss_dev = ltp_pci.dev->subsystem_device; - - temp = pci_find_subsys(ven, dev, ss_ven, ss_dev, NULL); - - if (!temp) { - printk("tpci: failed to find pci device from subsys info\n"); - rc = 1; - } else { - printk("tpci: found pci device from subsys info\n"); - rc = 0; - } - - return rc; -} - -/* - * test_scan_bus - * call to pci_do_scan_bus, which takes - * a struct pci_bus pointer, which will - * return a an integer for how far the - * function got in scanning bus - */ -static int test_scan_bus() -{ - int rc, num; - struct pci_bus *bus = ltp_pci.bus; - - num = pci_do_scan_bus(bus); - - /* - * check if returned number is greater than - * max number of bus or less than 0 - */ - if (num > MAX_BUS || num < 0) { - printk("tpci: Failed scan bus\n"); - rc = 1; - } else { - printk("tpci: Success scan bus\n"); - rc = 0; - } - - return rc; -} - -/* - * test_slot_scan - * make call to pci_scan_slot, which will - * find the device pointer and setup the - * device info - */ -static int test_slot_scan() -{ - int rc, ret; - int num = ltp_pci.dev->devfn; - struct pci_bus *bus = ltp_pci.bus; - - ret = pci_scan_slot(bus, num); - - if (ret > 0) { - printk("tpci: Found device from scan slot\n"); - rc = 0; - } else { - printk("tpci: Failed find device from scan slot\n"); - rc = 1; - } - - return rc; -} - -/* - * test_bus_add_devices - * make call to pci_bus_add_devices, - * which will check the device pointer - * that is passed in for more devices - * that it can add - */ -static int test_bus_add_devices() -{ - int rc; - struct pci_bus *bus = ltp_pci.bus; - - pci_bus_add_devices(bus); - - if (bus) { - printk("tpci: Called bus_add_device\n"); - rc = 0; - } else { - printk("tpci: bus_add_device failed\n"); - rc = 1; - } - - return rc; -} - -/* - * test_enable_bridges - * make call to pci_enable_bridges, - * use bus pointer from the ltp_pci - * structure - */ -static int test_enable_bridges() -{ - int rc; - struct pci_bus *bus = ltp_pci.bus; - - pci_enable_bridges(bus); - - if (bus) { - printk("tpci: Called enable bridges\n"); - rc = 0; - } else { - printk("tpci: enable_bridges failed\n"); - rc = 1; - } - - return rc; -} - -/* - * test_match_device - * make call to pci_match_device, returns a - * pci_device_id pointer - */ -static int test_match_device() -{ - int rc; - struct pci_dev *dev = ltp_pci.dev; - struct pci_driver *drv; - const struct pci_device_id *id; - - drv = pci_dev_driver(dev); - - if (!drv) { - printk("driver pointer not allocated for pci_dev\n"); - return 1; - } - - id = pci_match_device(drv->id_table, dev); - - if (id) { - printk("tpci: Match device success\n"); - rc = 0; - } else { - printk("tpci: Failed return pci_device_id \n"); - rc = 1; - } - - return rc; -} - -/* - * test_reg_driver - * make call to pci_register_driver, which will - * register the driver for a device with the - * system - */ -static int test_reg_driver() -{ - int rc, ret; - struct pci_driver *drv = - (struct pci_driver *)kmalloc(sizeof(struct pci_driver), GFP_KERNEL); - struct pci_driver *tmp = ltp_pci.dev->driver; - - /* zero out drv structure */ - memset(drv, 0, sizeof(struct pci_driver)); - - /* copy in structure of tmp, reset some fields */ - drv->name = "Tmod_driver"; - drv->driver = tmp->driver; - - /* copy structure into ltp_pci.drv */ - ltp_pci.drv = drv; - memcpy(ltp_pci.drv, drv, sizeof(struct pci_driver)); - - if (!drv) { - printk("tpci: Device does not have a driver pointer\n"); - return 1; - } - - ret = pci_register_driver(drv); - - if (ret) { - printk("tpci: Success driver register\n"); - rc = 0; - } else { - rc = 1; - printk("tpci: unsuccessful registering pci driver\n"); - } - - return rc; -} - -/* - * test_unreg_driver - * make call to pci_unregister_driver, which will - * unregister the driver for a device from the system - */ -static int test_unreg_driver() -{ - int rc; - struct pci_driver *drv = ltp_pci.drv; - - if (!drv) { - printk("tpci: Device does not have a driver pointer\n"); - return 1; - } - - pci_unregister_driver(drv); - if (!drv) { - printk("tpci: Unsuccesful driver unregister\n"); - rc = 1; - } else { - printk("tpci: unregistering pci driver\n"); - rc = 0; - } - - return rc; -} - -/* - * test_assign_resources - * make calls to pci_assign_resource, will need - * to setup a dev pointer and resource pointer, - */ -static int test_assign_resources() -{ - int rc; - struct pci_dev *dev = ltp_pci.dev; - int resno; - - for (resno = 0; resno < 7; resno++) { - struct resource *r = dev->resource + resno; - if (r->flags) - pci_assign_resource(dev, resno); - } - - /* - * enable device after call to assign resource - * because might error if (!r->start && r->end) - */ - rc = pci_enable_device(dev); - - return rc; -} - -/* - * test_save_state - * make call to pci_save_state, takes in a u32* - * buffer - */ -static int test_save_state() -{ - int rc; - u32 *buffer = ltp_pci.state; - struct pci_dev *dev = ltp_pci.dev; - - rc = pci_save_state(dev, buffer); - if (rc) - printk("tpci: Failed save state\n"); - else - printk("tpci: Saved state of device\n"); - - return rc; -} - -/* - * test_restore_state - * make call to pci_restore_state, get the state buffer - * should have been previously filled out by save state - */ -static int test_restore_state() -{ - int rc; - u32 *buffer = ltp_pci.state; - struct pci_dev *dev = ltp_pci.dev; - - rc = pci_restore_state(dev, buffer); - if (rc) - printk("tpci: Failed restore state\n"); - else - printk("tpci: Restored state of device\n"); - - return rc; -} - -/* - * test_max_bus - * make call to pci_max_busnr, which will determine - * the max number of bus on the system - */ -static int test_max_bus() -{ - int rc, ret; - - ret = pci_max_busnr(); - if (ret) { - printk("Found max busnr\n"); - rc = 0; - } else { - printk("Did not return max busnr\n"); - rc = 1; - } - - return rc; -} - -/* - * test_find_cap - * make call to pci_find_capability, which - * will determine if a device has a certain - * capability, use second parameter to specify - * which capability you are looking for - */ -static int test_find_cap() -{ - int rc; - struct pci_dev *dev = ltp_pci.dev; - - rc = pci_find_capability(dev, PCI_CAP_ID_PM); - if (rc) - printk("tpci: Does not have tested capability\n"); - else - printk("tpci: Device has PM capability\n"); - - return rc; -} - -/* - * test_find_pci_exp_cap - * make call to pci_find_capability, which will - * determine if a device has PCI-EXPRESS capability, - * use second parameter to specify which capability - * you are looking for - */ -static int test_find_pci_exp_cap() -{ - int rc; - struct pci_dev *dev = ltp_pci.dev; - - rc = pci_find_capability(dev, PCI_CAP_ID_EXP); - if (rc) - printk("tpci: Device has PCI-EXP capability\n"); - else - printk("tpci: Device doesn't have PCI-EXP capability\n"); - return rc; -} - -/* - * test_read_pci_exp_config - * make call to pci_config_read and determine if - * the PCI-Express enhanced config space of this - * device can be read successfully. - */ -static int test_read_pci_exp_config() -{ - int rc; - int reg = 100, len = 4; /*PCI-Exp enhanced config register 0x100, 4 implies dword access */ - struct pci_dev *dev = ltp_pci.dev; - - u32 data, *value; - - printk("tpci: Device(%d) on bus(%d) & slot(%d) \n", dev, - dev->bus->number, dev->devfn); - printk("tpci: Reading the PCI Express configuration registers---\n"); - - printk - ("tpci: Reading PCI-Express AER CAP-ID REGISTER at Enh-Cfg AddrSpace 0x100\n"); - - rc = pci_config_read(0, dev->bus->number, PCI_SLOT(dev->devfn), - PCI_FUNC(dev->devfn), reg, len, &data); - - *value = (u32) data; - - if (*value == AER_CAP_ID_VALUE) /*comparing the value read with AER_CAP_ID_VALUE macro */ - printk - ("tpci: \nCorrect value read using PCI-Express driver installed\n\n"); - else - printk - ("tpci: \nIncorrect value read. PCI-Express driver/device not installed\n\n"); - - return rc; -} - -/* - * tpci_init_module - * set the owner of tpci_fops, register the module - * as a char device, and perform any necessary - * initialization for pci devices - */ -static int tpci_init_module(void) -{ - int rc; - - SET_MODULE_OWNER(&tpci_fops); - - rc = register_chrdev(Major, DEVICE_NAME, &tpci_fops); - if (rc < 0) { - printk("tpci: Failed to register device.\n"); - return rc; - } - - if (Major == 0) - Major = rc; - - printk("tpci: Registration success.\n"); - return 0; -} - -/* - * tpci_exit_module - * unregister the device and any necessary - * operations to close for pci devices - */ -static void tpci_exit_module(void) -{ - int rc; - - kfree(ltp_pci.dev); - kfree(ltp_pci.bus); - kfree(ltp_pci.drv); - - rc = unregister_chrdev(Major, DEVICE_NAME); - if (rc < 0) - printk("tpci: unregister failed\n"); - else - printk("tpci: unregister success\n"); - -} - -module_init(tpci_init_module) - module_exit(tpci_exit_module) diff --git a/testcases/kernel/device-drivers/pci/tpci/tpci.h b/testcases/kernel/device-drivers/pci/tpci/tpci.h deleted file mode 100644 index bd81369..0000000 --- a/testcases/kernel/device-drivers/pci/tpci/tpci.h +++ /dev/null @@ -1,67 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#define TPCI_TEST_DRIVER_NAME "pci/pci-express test module" -#define TPCI_MAJOR 252 -#define DEVICE_NAME "/dev/tpci" -#define MAX_DEVFN 256 -#define MAX_BUS 256 -#define MAG_NUM 'k' -#define AER_CAP_ID_VALUE 0x14011 - -#define PCI_PROBE _IO(MAG_NUM, 1) -#define PCI_ENABLE _IO(MAG_NUM, 2) -#define PCI_DISABLE _IO(MAG_NUM, 3) -#define FIND_BUS _IO(MAG_NUM, 4) -#define FIND_DEVICE _IO(MAG_NUM, 5) -#define FIND_CLASS _IO(MAG_NUM, 6) -#define FIND_SUBSYS _IO(MAG_NUM, 7) -#define BUS_SCAN _IO(MAG_NUM, 8) -#define SLOT_SCAN _IO(MAG_NUM, 9) -#define ENABLE_BRIDGES _IO(MAG_NUM, 10) -#define BUS_ADD_DEVICES _IO(MAG_NUM, 11) -#define MATCH_DEVICE _IO(MAG_NUM, 12) -#define REG_DRIVER _IO(MAG_NUM, 13) -#define UNREG_DRIVER _IO(MAG_NUM, 14) -#define BUS_RESOURCES _IO(MAG_NUM, 15) -#define PCI_RESOURCES _IO(MAG_NUM, 16) -#define SAVE_STATE _IO(MAG_NUM, 19) -#define RESTORE_STATE _IO(MAG_NUM, 20) -#define TEST_MAX_BUS _IO(MAG_NUM, 21) -#define FIND_CAP _IO(MAG_NUM, 22) -#define FIND_PCI_EXP_CAP _IO(MAG_NUM, 23) -#define READ_PCI_EXP_CONFIG _IO(MAG_NUM, 24) -#ifndef SET_MODULE_OWNER -#define SET_MODULE_OWNER(dev) ((dev)->owner = THIS_MODULE) -#endif - -/* - * structures for PCI test driver - */ -struct tpci_interface { - int in_len; // input data length - caddr_t in_data; // input data - int out_rc; // return code from the test - int out_len; // output data length - caddr_t out_data; // output data -}; -typedef struct tpci_interface tpci_interface_t; - - diff --git a/testcases/kernel/device-drivers/pci/tpci/tpci.mod.c b/testcases/kernel/device-drivers/pci/tpci/tpci.mod.c deleted file mode 100644 index 0301727..0000000 --- a/testcases/kernel/device-drivers/pci/tpci/tpci.mod.c +++ /dev/null @@ -1,29 +0,0 @@ -#include <linux/module.h> -/* - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * -*/ -#include <linux/module.h> -#include <linux/vermagic.h> -#include <linux/compiler.h> - -const char vermagic[] - __attribute__ ((section("__vermagic"))) = VERMAGIC_STRING; - -static const char __module_depends[] - __attribute_used__ __attribute__ ((section(".modinfo"))) = "depends="; diff --git a/testcases/kernel/device-drivers/pci/tpci_kernel/.gitignore b/testcases/kernel/device-drivers/pci/tpci_kernel/.gitignore new file mode 100644 index 0000000..3e100ad --- /dev/null +++ b/testcases/kernel/device-drivers/pci/tpci_kernel/.gitignore @@ -0,0 +1,7 @@ +/ltp_tpci.ko +/*.mod.c +/modules.order +/.tmp_versions +/.*.ko +/.*.cmd +/Module.symvers diff --git a/testcases/kernel/device-drivers/pci/tpci_kernel/Makefile b/testcases/kernel/device-drivers/pci/tpci_kernel/Makefile new file mode 100644 index 0000000..02496af --- /dev/null +++ b/testcases/kernel/device-drivers/pci/tpci_kernel/Makefile @@ -0,0 +1,35 @@ +# Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. +# +# 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 would 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 the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +ifneq ($(KERNELRELEASE),) + +obj-m := ltp_tpci.o + +else + +top_srcdir ?= ../../../../.. + +include $(top_srcdir)/include/mk/env_pre.mk + +REQ_VERSION_MAJOR := 2 +REQ_VERSION_PATCH := 6 + +MAKE_TARGETS := ltp_tpci.ko + +include $(top_srcdir)/include/mk/module.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk + +endif \ No newline at end of file diff --git a/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c new file mode 100644 index 0000000..4e92f5e --- /dev/null +++ b/testcases/kernel/device-drivers/pci/tpci_kernel/ltp_tpci.c @@ -0,0 +1,787 @@ +/* + * Copyright (c) International Business Machines Corp., 2001 + * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * This pci and pci-express testing kernel module will allow test calls + * to be driven through various ioctl calls in a + * user space program that has attained the appropriate + * file descriptor for this device. For the functions of + * this module to work correctly there must be a pci / pci-express + * device somewhere in the system. The tests do not need + * a specific device, and the first pci device available + * will be grabbed. + * + * author: Sean Ruyle (sr...@us...) + * date: 5/20/2003 + * PCI-Express test scripts author: Amit Khanna (ami...@in...) + * date: 8/20/2004 + * + * file: tpci.c, + * module: tpci + */ + +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/fs.h> +#include <linux/ioctl.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/pci.h> + +#include "tpci.h" + +MODULE_AUTHOR("Sean Ruyle <sr...@us...>"); +MODULE_AUTHOR("Amit Khanna <ami...@in...>"); +MODULE_AUTHOR("Copyright (c) 2013 Oracle and/or its affiliates"); +MODULE_DESCRIPTION("LTP PCI Test"); +MODULE_LICENSE("GPL"); + +#define prk_err(fmt, ...) \ + pr_err(PCI_DEVICE_NAME ": " fmt "\n", ##__VA_ARGS__) +#define prk_info(fmt, ...) \ + pr_info(PCI_DEVICE_NAME ": " fmt "\n", ##__VA_ARGS__) +#define prk_debug(fmt, ...) \ + pr_debug(PCI_DEVICE_NAME ": " fmt "\n", ##__VA_ARGS__) + +#define TPASS 0 +#define TFAIL 1 +#define TSKIP 32 + +static DEFINE_PCI_DEVICE_TABLE(ltp_pci_tbl) = { + { PCI_DEVICE(PCI_ANY_ID, PCI_ANY_ID) }, + { 0, } +}; + +MODULE_DEVICE_TABLE(pci, ltp_pci_tbl); + +static int ltp_pci_probe(struct pci_dev *pci_dev, + const struct pci_device_id *pci_ent) +{ + return 0; +} + +static struct pci_driver ltp_pci_driver = { + .name = "LTP_PCI_DRIVER", + .id_table = ltp_pci_tbl, + .probe = ltp_pci_probe, +}; + +static int pci_registered; + +struct tpci_user { + struct pci_dev *dev; + struct pci_bus *bus; + struct pci_driver *drv; + uint32_t state[16]; +}; +static struct tpci_user ltp_pci; + +/* + * probe_pci_dev + * find a pci device that can be used for other test + * calls in this kernel module. + */ +static int probe_pci_dev(unsigned int bus, unsigned int slot) +{ + struct pci_dev *dev; + + prk_info("find arbitrary pci device for test"); + + if (ltp_pci.dev) { + pci_dev_put(ltp_pci.dev); + ltp_pci.dev = NULL; + } + + dev = pci_get_bus_and_slot(bus, slot); + if (!dev || !dev->driver) + return -ENODEV; + + prk_info("found pci_dev '%s', bus %u, devfn %u", + pci_name(dev), bus, slot); + + ltp_pci.dev = dev; + ltp_pci.bus = dev->bus; + prk_info("Bus number: %d", dev->bus->number); + return 0; +} + +/* + * pci_enable + * enable a pci device so that it may be used in + * later testing in the user test program + */ +static int pci_enable(void) +{ + struct pci_dev *dev = ltp_pci.dev; + + prk_info("enable pci device"); + + /* check if can enable the device pointer */ + if (!dev) { + prk_err("dev is NULL"); + return TFAIL; + } + + if (pci_enable_device(dev)) { + prk_err("failed to enable pci device"); + return TFAIL; + } + + prk_info("enabled pci device"); + return TPASS; +} + +static int pci_disable(void) +{ + struct pci_dev *dev = ltp_pci.dev; + + prk_info("disable pci device"); + + /* check if device pointer exists */ + if (!dev) { + prk_err("dev is NULL"); + return TFAIL; + } + + prk_info("is pci enabled '%d', is managed '%d'", + pci_is_enabled(dev), pci_is_managed(dev)); + + pci_release_regions(dev); + pci_disable_device(dev); + + if (dev->current_state == PCI_D3hot || + dev->current_state == PCI_D3cold) { + + prk_info("disabled pci device, state '%s'", + pci_power_name(dev->current_state)); + return TPASS; + + } + + prk_err("failed to disable pci device, state '%s'", + pci_power_name(dev->current_state)); + return TFAIL; +} + +/* + * find_bus + * call to pci_find_bus, use values from bus + * pointer in ltp_pci, make sure that returns + * bus with same values + */ +static int test_find_bus(void) +{ + int num = ltp_pci.bus->number; + struct pci_bus *temp = NULL; + + prk_info("find bus"); + + temp = pci_find_bus(pci_domain_nr(ltp_pci.bus), num); + + if (!temp) { + prk_info("pci_find_bus failed"); + return TFAIL; + } else if (temp->number != num) { + prk_err("returned bus pointer w/ wrong bus number"); + return TFAIL; + } + + prk_info("success returned bus pointer"); + return TPASS; +} + +/* + * find_class + * call to pci_find_class, using values from the + * pci_dev pointer in ltp_pci structure + */ +static int test_find_class(void) +{ + unsigned int num = ltp_pci.dev->class; + struct pci_dev *temp = NULL; + + prk_info("find pci class"); + + temp = pci_get_class(num, NULL); + + if (!temp) { + prk_err("failed to find pci device from class number"); + return TFAIL; + } + + prk_info("found pci device from class number"); + pci_dev_put(temp); + + return TPASS; +} + +/* + * find_device + * call to pci_find_device, using values for + * parameters from pci_dev pointer in the + * ltp_pci structure + */ +static int test_find_device(void) +{ + struct pci_dev *temp = NULL; + unsigned short ven = ltp_pci.dev->vendor, dev = ltp_pci.dev->device; + + prk_info("get pci device"); + + temp = pci_get_device(ven, dev, NULL); + + if (!temp) { + prk_err("failed to find pci device from device info"); + return TFAIL; + } + + prk_info("found pci device from device info"); + pci_dev_put(temp); + + return TPASS; +} + +/* + * find_subsys + * call to pci_find_subsys, use valued from + * pci_dev pointer in ltp_pci structure to + * find pci_dev from subsys info + */ +static int test_find_subsys(void) +{ + struct pci_dev *temp; + unsigned short ven = ltp_pci.dev->vendor, + dev = ltp_pci.dev->device, + ss_ven = ltp_pci.dev->subsystem_vendor, + ss_dev = ltp_pci.dev->subsystem_device; + + prk_info("get pci subsys"); + temp = pci_get_subsys(ven, dev, ss_ven, ss_dev, NULL); + + if (!temp) { + prk_err("failed to find pci device from subsys info"); + return TFAIL; + } + + prk_info("found pci device from subsys info"); + pci_dev_put(temp); + + return TPASS; +} + +/* + * test_scan_bus + * call to pci_do_scan_bus, which takes + * a struct pci_bus pointer, which will + * return an integer for how far the + * function got in scanning bus + */ +static int test_scan_bus(void) +{ +#ifdef CONFIG_HOTPLUG + int num; + struct pci_bus *bus = ltp_pci.bus; + + prk_info("scan pci bus"); + + num = pci_rescan_bus(bus); + /* + * check if returned number is greater than + * max number of bus or less than 0 + */ + if (num > MAX_BUS || num < 0) { + prk_err("failed scan bus"); + return TFAIL; + } + prk_info("success scan bus"); + return TPASS; +#else + prk_info("pci_rescan_bus() is not supported"); + return TSKIP; +#endif +} + +/* + * test_slot_scan + * make call to pci_scan_slot, which will + * find the device pointer and setup the + * device info + */ +static int test_slot_scan(void) +{ + int ret, num = ltp_pci.dev->devfn; + struct pci_bus *bus = ltp_pci.bus; + + prk_info("scan pci slot"); + + ret = pci_scan_slot(bus, num); + if (ret >= 0) { + prk_info("found '%d' devices from scan slot", ret); + return TPASS; + } + + prk_err("pci_scan_slot failed"); + return TFAIL; +} + +/* + * test_bus_add_devices + * make call to pci_bus_add_devices, + * which will check the device pointer + * that is passed in for more devices + * that it can add + */ +static int test_bus_add_devices(void) +{ + struct pci_bus *bus = ltp_pci.bus; + + prk_info("add bus device"); + + pci_bus_add_devices(bus); + + if (bus) { + prk_info("called bus_add_device"); + return TPASS; + } + + prk_err("bus_add_device failed"); + return TFAIL; +} + +/* + * test_enable_bridges + * make call to pci_enable_bridges, + * use bus pointer from the ltp_pci + * structure + */ +static int test_enable_bridges(void) +{ + struct pci_bus *bus = ltp_pci.bus; + + prk_info("enable bridges"); + + pci_enable_bridges(bus); + + if (bus) { + prk_info("called enable bridges"); + return TPASS; + } + + prk_err("enable_bridges failed"); + return TFAIL; +} + +/* + * test_match_device + * make call to pci_match_device, returns a + * pci_device_id pointer + */ +static int test_match_device(void) +{ + struct pci_dev *dev = ltp_pci.dev; + struct pci_driver *drv; + const struct pci_device_id *id; + + prk_info("test pci_device_id()"); + + drv = pci_dev_driver(dev); + + if (!drv) { + prk_err("driver pointer not allocated for pci_dev"); + return TFAIL; + } + + id = pci_match_id(drv->id_table, dev); + + if (id) { + prk_info("match device success"); + return TPASS; + } + + prk_err("failed return pci_device_id"); + return TFAIL; +} + + +/* + * test_reg_driver + * make call to pci_register_driver, which will + * register the driver for a device with the + * system + */ +static int test_reg_driver(void) +{ + prk_info("test pci_register_driver"); + if (pci_register_driver(<p_pci_driver)) { + prk_err("unsuccessful registering pci driver"); + return TFAIL; + } + pci_registered = 1; + prk_info("success driver register"); + return TPASS; +} + +/* + * test_unreg_driver + * make call to pci_unregister_driver, which will + * unregister the driver for a device from the system + */ +static int test_unreg_driver(void) +{ + pci_unregister_driver(<p_pci_driver); + pci_registered = 0; + return TPASS; +} + +/* + * test_assign_resources + * make calls to pci_assign_resource, will need + * to setup a dev pointer and resource pointer, + */ +static int test_assign_resources(void) +{ + int i, ret, rc = 0; + struct pci_dev *dev = ltp_pci.dev; + struct resource *r; + + prk_info("assign resources"); + + for (i = 0; i < 7; ++i) { + prk_info("assign resource #%d", i); + r = &dev->resource[i]; + prk_info("name = %s, flags = %lu, start 0x%lx, end 0x%lx", + r->name, r->flags, + (unsigned long)r->start, (unsigned long)r->end); + + if ((r->flags & IORESOURCE_MEM) == IORESOURCE_MEM) { + ret = pci_assign_resource(dev, i); + prk_info("assign resource to '%d', ret '%d'", i, ret); + rc |= (ret < 0 && ret != -EBUSY) ? TFAIL : TPASS; + } + } + + /* + * enable device after call to assign resource + * because might error if (!r->start && r->end) + */ + if (pci_enable_device(dev)) + return TFAIL; + + return rc; +} + +/* + * test_save_state + * make call to pci_save_state, takes in a u32* + * buffer + */ +static int test_save_state(void) +{ + struct pci_dev *dev = ltp_pci.dev; + + prk_info("save state"); + + if (pci_save_state(dev)) { + prk_err("failed save state"); + return TFAIL; + } + + prk_info("saved state of device"); + return TPASS; +} + +/* + * test_restore_state + * make call to pci_restore_state, get the state buffer + * should have been previously filled out by save state + */ +static int test_restore_state(void) +{ + struct pci_dev *dev = ltp_pci.dev; + + prk_info("restore state"); + + pci_restore_state(dev); + + return TPASS; +} + +/* + * test_find_cap + * make call to pci_find_capability, which + * will determine if a device has a certain + * capability, use second parameter to specify + * which capability you are looking for + */ +static int test_find_cap(void) +{ + struct pci_dev *dev = ltp_pci.dev; + + prk_info("find device capability"); + + if (pci_find_capability(dev, PCI_CAP_ID_PM)) + prk_info("does not have tested capability"); + else + prk_info("device has PM capability"); + + return TPASS; +} + +/* + * test_find_pci_exp_cap + * make call to pci_find_capability, which will + * determine if a device has PCI-EXPRESS capability, + * use second parameter to specify which capability + * you are looking for + */ +static int test_find_pci_exp_cap(void) +{ + struct pci_dev *dev = ltp_pci.dev; + + prk_info("find PCIe capability"); + + if (pci_find_capability(dev, PCI_CAP_ID_EXP)) { + prk_info("device has PCI-EXP capability"); + return TPASS; + } + + prk_info("device doesn't have PCI-EXP capability"); + return TFAIL; +} + +/* + * test_read_pci_exp_config + * make call to pci_config_read and determine if + * the PCI-Express enhanced config space of this + * device can be read successfully. + */ +static int test_read_pci_exp_config(void) +{ + /* PCI-Exp enhanced config register 0x100, 4 implies dword access */ + int reg = 100; + struct pci_dev *dev = ltp_pci.dev; + u32 data; + + /* skip the test if device doesn't have PCIe capability */ + if (test_find_pci_exp_cap() == TFAIL) + return TSKIP; + + prk_info("dev on bus(%d) & slot (%d)", dev->bus->number, dev->devfn); + prk_info("reading the PCI Express configuration registers---"); + prk_info("reading PCI-Express AER CAP-ID REGISTER at Enh-Cfg AddrSpace 0x100"); + + if (pci_read_config_dword(dev, reg, &data)) { + prk_err("failed to read config word"); + return TFAIL; + } + + /* comparing the value read with AER_CAP_ID_VALUE macro */ + if (data == AER_CAP_ID_VALUE) { + prk_info("correct val read using PCIE driver installed: '%u'", + data); + return TPASS; + } + + prk_err("incorrect val read. PCIE driver/device not installed: '%u'", + data); + return TFAIL; +} + + +static int test_case(unsigned int cmd) +{ + int rc = TSKIP; + + switch (cmd) { + case PCI_ENABLE: + rc = pci_enable(); + break; + case PCI_DISABLE: + rc = pci_disable(); + break; + case FIND_BUS: + rc = test_find_bus(); + break; + case FIND_CLASS: + rc = test_find_class(); + break; + case FIND_DEVICE: + rc = test_find_device(); + break; + case FIND_SUBSYS: + rc = test_find_subsys(); + break; + case BUS_SCAN: + rc = test_scan_bus(); + break; + case SLOT_SCAN: + rc = test_slot_scan(); + break; + case BUS_ADD_DEVICES: + rc = test_bus_add_devices(); + break; + case ENABLE_BRIDGES: + rc = test_enable_bridges(); + break; + case MATCH_DEVICE: + rc = test_match_device(); + break; + case REG_DRIVER: + rc = test_reg_driver(); + break; + case UNREG_DRIVER: + rc = test_unreg_driver(); + break; + case PCI_RESOURCES: + rc = test_assign_resources(); + break; + case SAVE_STATE: + rc = test_save_state(); + break; + case RESTORE_STATE: + rc = test_restore_state(); + break; + case FIND_CAP: + rc = test_find_cap(); + break; + case PCI_EXP_CAP_CONFIG: + rc = test_read_pci_exp_config(); + break; + default: + prk_info("mismatching test-case command %d", cmd); + break; + } + + return rc; +} + +/* + * Test-case result, + * if test is passed, value will be set to 0 + */ +static int test_result; + +static void device_release(struct device *dev) +{ + prk_info("device released\n"); +} + +static struct device tdev = { + .init_name = PCI_DEVICE_NAME, + .release = device_release, +}; + +/* print test result to sysfs file */ +static ssize_t sys_result(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return scnprintf(buf, PAGE_SIZE, "%d\n", test_result); +} +static DEVICE_ATTR(result, S_IRUSR, sys_result, NULL); + +static ssize_t sys_tcase(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int tc = 0; + + sscanf(buf, "%d", &tc); + prk_info("test-case %d", tc); + + test_result = test_case(tc); + + return count; +} +static DEVICE_ATTR(tcase, S_IWUSR, NULL, sys_tcase); + +static ssize_t sys_bus_slot(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + unsigned int res, bus, slot; + int ret; + + sscanf(buf, "%u", &res); + + bus = res >> 8 & 0xFF; + slot = res & 0xFF; + + prk_info("get bus '%u' slot '%u'", bus, slot); + + ret = probe_pci_dev(bus, slot); + if (ret) + return ret; + + return count; +} +static DEVICE_ATTR(bus_slot, S_IWUSR, NULL, sys_bus_slot); + +static int tpci_init_module(void) +{ + int err = 0; + prk_info("Starting module"); + + err = device_register(&tdev); + if (err) { + prk_err("Unable to register device"); + goto err0; + } + prk_info("device registered\n"); + + err = device_create_file(&tdev, &dev_attr_result); + if (err) { + prk_err("Can't create sysfs file 'result'"); + goto err1; + } + + err = device_create_file(&tdev, &dev_attr_tcase); + if (err) { + prk_err(": Can't create sysfs file 'tc'"); + goto err2; + } + + err = device_create_file(&tdev, &dev_attr_bus_slot); + if (err) { + prk_err(": Can't create sysfs file 'bus_slot'"); + goto err3; + } + + return 0; + +err3: + device_remove_file(&tdev, &dev_attr_tcase); +err2: + device_remove_file(&tdev, &dev_attr_result); +err1: + device_unregister(&tdev); +err0: + return err; +} +module_init(tpci_init_module) + +static void tpci_exit_module(void) +{ + prk_debug("Unloading module\n"); + if (ltp_pci.dev) + pci_dev_put(ltp_pci.dev); + + if (pci_registered) + pci_unregister_driver(<p_pci_driver); + + device_remove_file(&tdev, &dev_attr_result); + device_remove_file(&tdev, &dev_attr_tcase); + device_unregister(&tdev); +} +module_exit(tpci_exit_module) diff --git a/testcases/kernel/device-drivers/pci/tpci/pci-exp-tests-HOWTO b/testcases/kernel/device-drivers/pci/tpci_kernel/pci-exp-tests-HOWTO similarity index 100% rename from testcases/kernel/device-drivers/pci/tpci/pci-exp-tests-HOWTO rename to testcases/kernel/device-drivers/pci/tpci_kernel/pci-exp-tests-HOWTO diff --git a/testcases/kernel/device-drivers/pci/tpci_kernel/tpci.h b/testcases/kernel/device-drivers/pci/tpci_kernel/tpci.h new file mode 100644 index 0000000..d5ee669 --- /dev/null +++ b/testcases/kernel/device-drivers/pci/tpci_kernel/tpci.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) International Business Machines Corp., 2001 + * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See + * the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#define PCI_DEVICE_NAME "ltp_tpci" +#define MAX_DEVFN 256 +#define MAX_BUS 256 +#define AER_CAP_ID_VALUE 0x14011 + +enum PCI_TCASES { + PCI_DISABLE = 0, + PCI_ENABLE, + FIND_BUS, + FIND_DEVICE, + FIND_CLASS, + FIND_SUBSYS, + BUS_SCAN, + SLOT_SCAN, + ENABLE_BRIDGES, + BUS_ADD_DEVICES, + MATCH_DEVICE, + REG_DRIVER, + UNREG_DRIVER, + PCI_RESOURCES, + SAVE_STATE, + RESTORE_STATE, + FIND_CAP, + PCI_EXP_CAP_CONFIG, + PCI_TCASES_NUM, +}; diff --git a/testcases/kernel/device-drivers/pci/tpci_user/.gitignore b/testcases/kernel/device-drivers/pci/tpci_user/.gitignore new file mode 100644 index 0000000..b1817e5 --- /dev/null +++ b/testcases/kernel/device-drivers/pci/tpci_user/.gitignore @@ -0,0 +1 @@ +/tpci diff --git a/testcases/kernel/device-drivers/block/block_dev_user/Makefile b/testcases/kernel/device-drivers/pci/tpci_user/Makefile similarity index 100% copy from testcases/kernel/device-drivers/block/block_dev_user/Makefile copy to testcases/kernel/device-drivers/pci/tpci_user/Makefile diff --git a/testcases/kernel/device-drivers/pci/tpci_user/tpci.c b/testcases/kernel/device-drivers/pci/tpci_user/tpci.c new file mode 100644 index 0000000..f121a18 --- /dev/null +++ b/testcases/kernel/device-drivers/pci/tpci_user/tpci.c @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. + * + * 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 would 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 the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: Alexey Kodanev <ale...@or...> + * + */ + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> + +#include "test.h" +#include "usctest.h" +#include "safe_macros.h" +#include "tst_module.h" + +#include "../tpci_kernel/tpci.h" + +char *TCID = "test_pci"; +int TST_TOTAL = PCI_TCASES_NUM; + +static const char module_name[] = PCI_DEVICE_NAME ".ko"; +static const char dev_result[] = "/sys/devices/" PCI_DEVICE_NAME "/result"; +static const char dev_tcase[] = "/sys/devices/" PCI_DEVICE_NAME "/tcase"; +static const char dev_busslot[] = "/sys/devices/" PCI_DEVICE_NAME "/bus_slot"; +static int module_loaded; + +static void cleanup(void) +{ + if (module_loaded) + tst_module_unload(NULL, module_name); + + TEST_CLEANUP; +} + +void setup(int argc, char *argv[]) +{ + tst_require_root(NULL); + + if (tst_kvercmp(2, 6, 0) < 0) { + tst_brkm(TCONF, NULL, + "Test must be run with kernel 2.6 or newer"); + } + + tst_sig(FORK, DEF_HANDLER, cleanup); +} + +static void run_pci_testcases(int bus, int slot) +{ + int i, res; + for (i = 0; i < TST_TOTAL; ++i) { + /* skip pci disable test-case, it is manual */ + if (i == PCI_DISABLE) + continue; + + SAFE_FILE_PRINTF(cleanup, dev_tcase, "%d", i); + SAFE_FILE_SCANF(cleanup, dev_result, "%d", &res); + + tst_resm(res, "PCI bus %02x slot %02x : Test-case '%d'", + bus, slot, i); + } +} + +static void test_run(void) +{ + tst_module_load(cleanup, module_name, NULL); + module_loaded = 1; + + char buf[6]; + int i, j, fd, count; + + for (i = 0; i < MAX_BUS; ++i) { + for (j = 0; j < MAX_DEVFN; ++j) { + /* set pci device for the test */ + fd = SAFE_OPEN(cleanup, dev_busslot, O_WRONLY); + count = snprintf(buf, 6, "%u", i << 8 | j); + errno = 0; + if (write(fd, buf, count) < 0) { + if (errno == ENODEV) { + SAFE_CLOSE(cleanup, fd); + continue; + } + tst_brkm(TBROK | TERRNO, cleanup, + "write to '%s' failed", dev_busslot); + } + SAFE_CLOSE(cleanup, fd); + + run_pci_testcases(i, j); + + } + } +} + +int main(int argc, char *argv[]) +{ + setup(argc, argv); + + test_run(); + + cleanup(); + + tst_exit(); +} diff --git a/testcases/kernel/device-drivers/pci/user_tpci/Makefile b/testcases/kernel/device-drivers/pci/user_tpci/Makefile deleted file mode 100644 index 38ed3eb..0000000 --- a/testcases/kernel/device-drivers/pci/user_tpci/Makefile +++ /dev/null @@ -1,9 +0,0 @@ - -CFLAGS += -Wall -OBJS = tpci_ki.o user_tpci.o - -test_pci: $(OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ - -clean: - rm -f $(OBJS) test_pci diff --git a/testcases/kernel/device-drivers/pci/user_tpci/tpci_ki.c b/testcases/kernel/device-drivers/pci/user_tpci/tpci_ki.c deleted file mode 100644 index 91e1471..0000000 --- a/testcases/kernel/device-drivers/pci/user_tpci/tpci_ki.c +++ /dev/null @@ -1,198 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - - * This file will include user space functions that will drive - * the kernel module tpci to test various pci functions - * and kernel calls. Each function will need to setup the tif - * structure so that the in parameters and out parameters - * are correctly initialized - * - * use tif structure for passing params between user - * space and kernel space, in some tests it is really - * not needed but makes easy to maintain all tests if - * have the same process to read in params in the - * kernel module no matter what the test is - * - * author: Sean Ruyle (sr...@us...) - * date: 5/21/2003 - * - * tpci_ki.c - */ - -#include <stdlib.h> -#include <stdio.h> -#include <sys/ioctl.h> -#include "../tpci/tpci.h" - -int ki_generic(int fd, int flag) -{ - int rc; - tpci_interface_t tif; - - /* - * build interface structure - */ - tif.in_len = 0; - tif.in_data = 0; - tif.out_len = 0; - tif.out_data = 0; - tif.out_rc = 0; - - /* - * ioctl call for flag - */ - rc = ioctl(fd, flag, &tif); - if (rc) { - printf("Ioctl error\n"); - return rc; - } - if (tif.out_rc) { - printf("Specific errorr: "); - return tif.out_rc; - } - - return rc; -} - -#if 0 -int ki_probe_pci_dev(int fd) -{ - - int rc; - tpci_interface_t tif; - - /* - * build interface structure - */ - tif.in_len = 0; - tif.in_data = 0; - tif.out_len = 0; - tif.out_data = 0; - tif.out_rc = 0; - - /* - * ioctl call for PCI_PROBE - */ - rc = ioctl(fd, PCI_PROBE, &tif); - if (rc) { - printf("Ioctl error\n"); - return rc; - } - if (tif.out_rc) { - printf("Specific error in ioctl call\n"); - return tif.out_rc; - } - - return rc; -} - -int ki_enable_pci(int fd) -{ - - int rc; - tpci_interface_t tif; - - /* - * build interface structure - */ - tif.in_len = 0; - tif.in_data = 0; - tif.out_len = 0; - tif.out_data = 0; - tif.out_rc = 0; - - /* - * ioctl call for PCI_ENABLE - */ - rc = ioctl(fd, PCI_ENABLE, &tif); - if (rc) { - printf("Ioctl error\n"); - return rc; - } - if (tif.out_rc) { - printf("Specific error in ioctl call\n"); - return tif.out_rc; - } - - return rc; -} - -int ki_disable_pci(int fd) -{ - - int rc; - tpci_interface_t tif; - - /* - * build interface structure - */ - tif.in_len = 0; - tif.in_data = 0; - tif.out_len = 0; - tif.out_data = 0; - tif.out_rc = 0; - - /* - * ioctl call for PCI_DISABLE - */ - rc = ioctl(fd, PCI_DISABLE, &tif); - if (rc) { - printf("Ioctl error\n"); - return rc; - } - if (tif.out_rc) { - printf("Specific error in ioctl call\n"); - return tif.out_rc; - } - - return rc; -} - -int ki_find_bus(int fd) -{ - - int rc; - tpci_interface_t tif; - - /* - * build interface structure - */ - tif.in_len = 0; - tif.in_data = 0; - tif.out_len = 0; - tif.out_data = 0; - tif.out_rc = 0; - - /* - * ioctl call for PCI_DISABLE - */ - rc = ioctl(fd, FIND_BUS, &tif); - if (rc) { - printf("Ioctl error\n"); - return rc; - } - if (tif.out_rc) { - printf("Specific error in ioctl call\n"); - return tif.out_rc; - } - - return rc; -} - -#endif diff --git a/testcases/kernel/device-drivers/pci/user_tpci/user_tpci.c b/testcases/kernel/device-drivers/pci/user_tpci/user_tpci.c deleted file mode 100644 index 3d4cc45..0000000 --- a/testcases/kernel/device-drivers/pci/user_tpci/user_tpci.c +++ /dev/null @@ -1,258 +0,0 @@ -#include <stdio.h> -/* - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <stdio.h> -#include <stdlib.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <errno.h> -#include <linux/kernel.h> -#include <linux/... [truncated message content] |
From: Cyril H. <su...@li...> - 2013-10-15 12:51:14
|
The branch, master, has been updated via e2ecf28cbbcb99ff5ff576ad0c1ce7145d28bf76 (commit) from 9ca9633cb75c407a81b98673891982b2e0702b29 (commit) - Log ----------------------------------------------------------------- commit e2ecf28cbbcb99ff5ff576ad0c1ce7145d28bf76 Author: Cyril Hrubis <ch...@su...> Date: Tue Oct 15 14:33:58 2013 +0200 syscalls: mount: Simplify the -T param handling. Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/mount/mount03.c | 16 ++++------------ testcases/kernel/syscalls/mount/mount05.c | 17 +++++------------ 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c index a3721d7..f8a3083 100644 --- a/testcases/kernel/syscalls/mount/mount03.c +++ b/testcases/kernel/syscalls/mount/mount03.c @@ -56,19 +56,15 @@ static int test_rwflag(int, int); char *TCID = "mount03"; int TST_TOTAL = 7; -#define DEFAULT_FSTYPE "ext2" #define TEMP_FILE "temp_file" #define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) #define DIR_MODE (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \ S_IXGRP|S_IROTH|S_IXOTH) #define SUID_MODE (S_ISUID|S_IRUSR|S_IXUSR|S_IXGRP|S_IXOTH) -static const char *fs_type = "ext2"; - static const char mntpoint[] = "mntpoint"; -static char *fstype; +static char *fstype = "ext2"; static char *device; -static int tflag; static int dflag; static int fildes; @@ -88,7 +84,7 @@ long rwflags[] = { }; static option_t options[] = { - {"T:", &tflag, &fstype}, + {"T:", NULL, &fstype}, {"D:", &dflag, &device}, {NULL, NULL, NULL} }; @@ -108,10 +104,6 @@ int main(int argc, char *argv[]) "you must specify the device used for mounting with -D " "option"); - if (tflag) - fs_type = fstype; - - if (STD_COPIES != 1) { tst_resm(TINFO, "-c option has no effect for this testcase - " "%s doesn't allow running more than one instance " @@ -127,7 +119,7 @@ int main(int argc, char *argv[]) for (i = 0; i < TST_TOTAL; ++i) { - TEST(mount(device, mntpoint, fs_type, rwflags[i], + TEST(mount(device, mntpoint, fstype, rwflags[i], NULL)); if (TEST_RETURN != 0) { @@ -274,7 +266,7 @@ int test_rwflag(int i, int cnt) case 4: /* Validate MS_REMOUNT flag of mount call */ - TEST(mount(device, mntpoint, fs_type, MS_REMOUNT, NULL)); + TEST(mount(device, mntpoint, fstype, MS_REMOUNT, NULL)); if (TEST_RETURN != 0) { tst_resm(TWARN | TTERRNO, "mount(2) failed to remount"); return 1; diff --git a/testcases/kernel/syscalls/mount/mount05.c b/testcases/kernel/syscalls/mount/mount05.c index fb5a385..6c1ccfd 100644 --- a/testcases/kernel/syscalls/mount/mount05.c +++ b/testcases/kernel/syscalls/mount/mount05.c @@ -43,11 +43,8 @@ int TST_TOTAL = 1; #define DIR_MODE (S_IRWXU | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP) -static const char *fs_type = "ext2"; - -static int tflag; static int dflag; -static char *fstype; +static char *fstype = "ext2"; static char *device; static const char file_src[] = "mnt_src/tstfile"; static const char file_des[] = "mnt_des/tstfile"; @@ -55,7 +52,7 @@ static const char mntpoint_src[] = "mnt_src"; static const char mntpoint_des[] = "mnt_des"; static option_t options[] = { - {"T:", &tflag, &fstype}, + {"T:", NULL, &fstype}, {"D:", &dflag, &device}, {NULL, NULL, NULL}, }; @@ -69,9 +66,6 @@ int main(int argc, char *argv[]) if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - if (tflag) - fs_type = fstype; - if (STD_COPIES != 1) { tst_resm(TINFO, "-c option has no effect for this testcase - " "%s doesn't allow running more than one instance " @@ -85,7 +79,7 @@ int main(int argc, char *argv[]) tst_count = 0; - TEST(mount(mntpoint_src, mntpoint_des, fs_type, MS_BIND, NULL)); + TEST(mount(mntpoint_src, mntpoint_des, fstype, MS_BIND, NULL)); if (TEST_RETURN != 0) { tst_resm(TFAIL | TTERRNO, "mount(2) failed"); @@ -106,7 +100,6 @@ int main(int argc, char *argv[]) } cleanup(); - tst_exit(); } @@ -122,9 +115,9 @@ void setup(void) SAFE_MKDIR(cleanup, mntpoint_des, DIR_MODE); if (dflag) { - tst_mkfs(NULL, device, fs_type, NULL); + tst_mkfs(NULL, device, fstype, NULL); - if (mount(device, mntpoint_src, fs_type, 0, NULL) == -1) + if (mount(device, mntpoint_src, fstype, 0, NULL) == -1) tst_brkm(TBROK | TERRNO, cleanup, "mount failed"); } hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-14 15:51:16
|
The branch, master, has been updated via 9ca9633cb75c407a81b98673891982b2e0702b29 (commit) from 6f3147f01229f3bb953202cde828d35e0d2bcb8a (commit) - Log ----------------------------------------------------------------- commit 9ca9633cb75c407a81b98673891982b2e0702b29 Author: Cyril Hrubis <ch...@su...> Date: Mon Oct 14 17:06:47 2013 +0200 openposix: Remove unreachable code. Change all occurences of: int main(void) { ... if (failed) { printf("Test FAILED\n"); return PTS_FAIL; } else { printf("Test PASSED\n"); return PTS_PASS; } printf("This code should not be executed\n"); return PTS_UNRESOLVED; } And similar for: int main(void) { ... if (failed) { printf("Test FAILED\n"); return PTS_FAIL; } printf("Test PASSED\n"); return PTS_PASS; } To remove unreachable code. Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: .../conformance/interfaces/clock_getres/5-1.c | 7 ++----- .../conformance/interfaces/clock_getres/6-2.c | 7 ++----- .../conformance/interfaces/clock_gettime/1-1.c | 7 ++----- .../conformance/interfaces/clock_gettime/1-2.c | 5 +---- .../conformance/interfaces/clock_gettime/2-1.c | 5 +---- .../conformance/interfaces/clock_gettime/3-1.c | 10 +++------- .../conformance/interfaces/clock_gettime/4-1.c | 10 +++------- .../conformance/interfaces/clock_gettime/7-1.c | 7 ++----- .../conformance/interfaces/clock_gettime/8-1.c | 5 +---- .../conformance/interfaces/clock_gettime/8-2.c | 7 ++----- .../conformance/interfaces/clock_nanosleep/1-1.c | 7 ++----- .../conformance/interfaces/clock_nanosleep/13-1.c | 7 ++----- .../conformance/interfaces/clock_nanosleep/2-1.c | 7 ++----- .../conformance/interfaces/clock_nanosleep/3-1.c | 7 ++----- .../conformance/interfaces/clock_settime/1-1.c | 6 +----- .../conformance/interfaces/clock_settime/17-1.c | 5 +---- .../conformance/interfaces/clock_settime/17-2.c | 7 ++----- .../conformance/interfaces/clock_settime/4-1.c | 11 ++++------- .../conformance/interfaces/clock_settime/5-2.c | 11 ++++------- .../conformance/interfaces/nanosleep/1-1.c | 7 ++----- .../conformance/interfaces/nanosleep/2-1.c | 8 +++----- .../conformance/interfaces/nanosleep/5-1.c | 7 ++----- .../interfaces/sched_get_priority_max/1-1.c | 7 ++----- .../interfaces/sched_get_priority_max/1-2.c | 7 ++----- .../interfaces/sched_get_priority_max/1-3.c | 7 ++----- .../interfaces/sched_get_priority_max/1-4.c | 7 ++----- .../interfaces/sched_get_priority_max/2-1.c | 5 +---- .../interfaces/sched_get_priority_min/1-1.c | 7 ++----- .../interfaces/sched_get_priority_min/1-2.c | 7 ++----- .../interfaces/sched_get_priority_min/1-3.c | 7 ++----- .../interfaces/sched_get_priority_min/1-4.c | 7 ++----- .../interfaces/sched_get_priority_min/2-1.c | 5 +---- .../conformance/interfaces/sched_getparam/1-1.c | 12 +++++++++--- .../conformance/interfaces/sched_getparam/2-1.c | 9 +++------ .../conformance/interfaces/sched_getparam/3-1.c | 6 +----- .../interfaces/sched_getscheduler/1-1.c | 11 +++++------ .../conformance/interfaces/sem_post/4-1.c | 8 +++----- .../conformance/interfaces/timer_create/1-1.c | 11 ++++------- .../conformance/interfaces/timer_delete/1-2.c | 7 ++----- .../conformance/interfaces/timer_getoverrun/1-1.c | 9 +++------ .../conformance/interfaces/timer_getoverrun/2-1.c | 9 +++------ .../conformance/interfaces/timer_getoverrun/2-3.c | 9 +++------ .../conformance/interfaces/timer_gettime/1-1.c | 11 ++++------- .../conformance/interfaces/timer_gettime/1-2.c | 11 ++++------- .../conformance/interfaces/timer_gettime/1-4.c | 11 ++++------- .../conformance/interfaces/timer_gettime/2-2.c | 11 ++++------- .../conformance/interfaces/timer_gettime/3-1.c | 11 ++++------- .../conformance/interfaces/timer_settime/1-1.c | 11 ++++------- .../conformance/interfaces/timer_settime/1-2.c | 7 ++----- .../conformance/interfaces/timer_settime/13-1.c | 7 ++----- .../conformance/interfaces/timer_settime/5-1.c | 11 ++++------- .../conformance/interfaces/timer_settime/8-1.c | 15 ++++++--------- .../conformance/interfaces/timer_settime/8-2.c | 17 +++++++---------- .../conformance/interfaces/timer_settime/8-3.c | 9 +++------ .../conformance/interfaces/timer_settime/8-4.c | 9 +++------ 55 files changed, 151 insertions(+), 307 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/5-1.c index 7547f33..a7c48d8 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/5-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/5-1.c @@ -20,11 +20,8 @@ int main(void) if (clock_getres(INVALIDCLOCKID, &res) == -1) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Test FAILED\n"); - return PTS_FAIL; } - printf("This code should not be executed\n"); - return PTS_UNRESOLVED; + printf("Test FAILED\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/6-2.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/6-2.c index 11a2033..c448090 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/6-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/6-2.c @@ -54,11 +54,8 @@ int main(void) if (failure) { printf("At least one test FAILED -- see above\n"); return PTS_FAIL; - } else { - printf("All tests PASSED\n"); - return PTS_PASS; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("All tests PASSED\n"); + return PTS_PASS; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/1-1.c index 5ab834f..4e8dd84 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/1-1.c @@ -27,11 +27,8 @@ int main(void) printf("clock_gettime() success, but tp not filled\n"); return PTS_FAIL; } - } else { - printf("clock_gettime() failed\n"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("clock_gettime() failed\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/1-2.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/1-2.c index e8838a4..b5b698f 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/1-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/1-2.c @@ -43,11 +43,8 @@ int main(void) perror("Error calling gettimeofday()\n"); return PTS_UNRESOLVED; } - } else { - printf("clock_gettime() failed\n"); - return PTS_UNRESOLVED; } - printf("This code should not be executed.\n"); + printf("clock_gettime() failed\n"); return PTS_UNRESOLVED; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/2-1.c index 1b056a2..128169c 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/2-1.c @@ -43,11 +43,8 @@ int main(void) perror("Error calling gettimeofday()\n"); return PTS_UNRESOLVED; } - } else { - printf("clock_gettime() failed\n"); - return PTS_UNRESOLVED; } - printf("This code should not be executed.\n"); + printf("clock_gettime() failed\n"); return PTS_UNRESOLVED; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/3-1.c index 5a82935..910224e 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/3-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/3-1.c @@ -55,17 +55,13 @@ int main(void) (ts2.tv_sec <= ts3.tv_sec) && (ts3.tv_sec <= ts4.tv_sec)) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Test FAILED - ts1=%ld,ts2=%ld,ts3=%ld,ts4=%ld\n", - ts1.tv_sec, ts2.tv_sec, ts3.tv_sec, ts4.tv_sec); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Test FAILED - ts1=%ld,ts2=%ld,ts3=%ld,ts4=%ld\n", + ts1.tv_sec, ts2.tv_sec, ts3.tv_sec, ts4.tv_sec); + return PTS_FAIL; #else printf("CLOCK_MONOTONIC unsupported\n"); return PTS_UNSUPPORTED; #endif - } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/4-1.c index f65a867..0830ee1 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/4-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/4-1.c @@ -71,18 +71,14 @@ int main(void) (ts2.tv_sec <= ts3.tv_sec) && (ts3.tv_sec <= ts4.tv_sec)) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Test FAILED - ts1=%ld,ts2=%ld,ts3=%ld,ts4=%ld\n", - ts1.tv_sec, ts2.tv_sec, ts3.tv_sec, ts4.tv_sec); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Test FAILED - ts1=%ld,ts2=%ld,ts3=%ld,ts4=%ld\n", + ts1.tv_sec, ts2.tv_sec, ts3.tv_sec, ts4.tv_sec); + return PTS_FAIL; #else printf("CLOCK_PROCESS_CPUTIME_ID unsupported\n"); return PTS_UNSUPPORTED; #endif #endif - } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/7-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/7-1.c index 8fbb867..5968b38 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/7-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/7-1.c @@ -19,11 +19,8 @@ int main(void) if (clock_gettime(INVALIDCLOCK, &tp) == -1) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Test FAILED\n"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Test FAILED\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/8-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/8-1.c index c3d4520..eea8e9b 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/8-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/8-1.c @@ -27,11 +27,8 @@ int main(void) printf("Test FAILED\n"); return PTS_FAIL; } - } else { - printf("clock_gettime() did not return failure\n"); - return PTS_UNRESOLVED; } - printf("This code should not be executed.\n"); + printf("clock_gettime() did not return failure\n"); return PTS_UNRESOLVED; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/8-2.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/8-2.c index 1385916..ed4cd40 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/8-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/8-2.c @@ -52,11 +52,8 @@ int main(void) if (failure) { printf("At least one test FAILED -- see above\n"); return PTS_FAIL; - } else { - printf("Test PASSED\n"); - return PTS_PASS; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Test PASSED\n"); + return PTS_PASS; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-1.c index 2b2bc78..7647003 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-1.c @@ -50,11 +50,8 @@ int main(void) if ((slepts > 0) || (sleptns > SLEEPNSEC)) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("clock_nanosleep() did not sleep long enough\n"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("clock_nanosleep() did not sleep long enough\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/13-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/13-1.c index 038f00a..8cf13eb 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/13-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/13-1.c @@ -27,11 +27,8 @@ int main(void) if (clock_nanosleep(BOGUSCLOCKID, 0, &tssleep, NULL) == EINVAL) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("errno != EINVAL\n"); - return PTS_FAIL; } - printf("This code should not be executed\n"); - return PTS_UNRESOLVED; + printf("errno != EINVAL\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/2-1.c index a875e17..5419aef 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/2-1.c @@ -54,11 +54,8 @@ int main(void) printf("clock_nanosleep() slept too long\n"); return PTS_FAIL; } - } else { - printf("clock_nanosleep() did not sleep long enough\n"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("clock_nanosleep() did not sleep long enough\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/3-1.c index 18e7a54..287d85d 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/3-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/3-1.c @@ -55,11 +55,8 @@ int main(void) printf("FAIL: clock_nanosleep() slept\n"); return PTS_FAIL; } - } else { - printf("FAIL: error in clock_gettime()\n"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("FAIL: error in clock_gettime()\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/1-1.c index 74cfc0a..a39e2a6 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/1-1.c @@ -67,13 +67,9 @@ int main(void) setBackTime(tpreset); return PTS_FAIL; } - } else { - printf("clock_settime() failed\n"); - setBackTime(tpreset); - return PTS_UNRESOLVED; } - printf("This code should not be executed.\n"); + printf("clock_settime() failed\n"); setBackTime(tpreset); return PTS_UNRESOLVED; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/17-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/17-1.c index 90b0162..af3a587 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/17-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/17-1.c @@ -39,11 +39,8 @@ int main(void) printf("errno != EINVAL\n"); return PTS_FAIL; } - } else { - printf("clock_settime() did not return -1\n"); - return PTS_UNRESOLVED; } - printf("This test should not be executed.\n"); + printf("clock_settime() did not return -1\n"); return PTS_UNRESOLVED; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/17-2.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/17-2.c index 72e34dd..990e414 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/17-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/17-2.c @@ -66,11 +66,8 @@ int main(void) if (failure) { printf("At least one test FAILED -- see above\n"); return PTS_FAIL; - } else { - printf("All tests PASSED\n"); - return PTS_PASS; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("All tests PASSED\n"); + return PTS_PASS; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/4-1.c index 4cb6bc0..f8a3e9c 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/4-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/4-1.c @@ -12,7 +12,7 @@ * - get time T0 * - create/enable a timer to expire at T1 = T0 + TIMEROFFSET * - sleep SLEEPTIME seconds (SLEEPTIME should be < TIMEROFFSET, - * but > ACCEPTABLEDELTA) + * but > ACCEPTABLEDELTA) * - set time back to T0 * - wait for the timer to expire * - get time T2 @@ -124,12 +124,9 @@ int main(void) if ((delta <= ACCEPTABLEDELTA) && (delta >= 0)) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("FAIL: Ended %d, not %d\n", - (int)tpT2.tv_sec, (int)its.it_value.tv_sec); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("FAIL: Ended %d, not %d\n", + (int)tpT2.tv_sec, (int)its.it_value.tv_sec); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-2.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-2.c index 27cd54e..90badb8 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/5-2.c @@ -122,13 +122,10 @@ int main(void) tsreset.tv_sec += TIMERSEC; setBackTime(tsreset); return PTS_PASS; - } else { - printf("Timer did not last for correct amount of time\n"); - printf("timer: %d != correct %d\n", - (int)ts.tv_sec - (int)tsleft.tv_sec, TIMERSEC); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Timer did not last for correct amount of time\n"); + printf("timer: %d != correct %d\n", + (int)ts.tv_sec - (int)tsleft.tv_sec, TIMERSEC); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/1-1.c index 96303ba..687d01e 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/1-1.c @@ -48,11 +48,8 @@ int main(void) if ((slepts > 0) || (sleptns > sleepnsec)) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("nanosleep() did not sleep long enough\n"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("nanosleep() did not sleep long enough\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/2-1.c index 45a509e..cce3941 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/2-1.c @@ -66,10 +66,8 @@ int main(void) if (failure) { printf("At least one test FAILED\n"); return PTS_FAIL; - } else { - printf("All tests PASSED\n"); - return PTS_PASS; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + + printf("All tests PASSED\n"); + return PTS_PASS; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/5-1.c index c97691a..f26e7f5 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/5-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/5-1.c @@ -22,11 +22,8 @@ int main(void) if (nanosleep(&tssleepfor, &tsstorage) == -1) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("nanosleep() did not return -1 on failure\n"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("nanosleep() did not return -1 on failure\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-1.c index 03d28a4..1115bf5 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-1.c @@ -27,11 +27,8 @@ int main(void) result); printf("Test PASSED\n"); return PTS_PASS; - } else { - perror("An error occurs"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + perror("An error occurs"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-2.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-2.c index 640198a..446a0d0 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-2.c @@ -27,11 +27,8 @@ int main(void) result); printf("Test PASSED\n"); return PTS_PASS; - } else { - perror("An error occurs"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + perror("An error occurs"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-3.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-3.c index df43d3e..092c47b 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-3.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-3.c @@ -31,13 +31,10 @@ int main(void) result); printf("Test PASSED\n"); return PTS_PASS; - } else { - perror("An error occurs"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + perror("An error occurs"); + return PTS_FAIL; } #else int main(void) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-4.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-4.c index d1b28a2..25efb95 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-4.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/1-4.c @@ -27,11 +27,8 @@ int main(void) result); printf("Test PASSED\n"); return PTS_PASS; - } else { - perror("An error occurs"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + perror("An error occurs"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/2-1.c index 584a39d..fee605d 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/2-1.c @@ -34,11 +34,8 @@ int main(void) if (errno != EINVAL) { perror("error is not EINVAL"); return PTS_FAIL; - } else { - printf("Unresolved test error\n"); - return PTS_UNRESOLVED; } - printf("This code should not be executed.\n"); + printf("Unresolved test error\n"); return PTS_UNRESOLVED; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-1.c index 9f4841d..94d8dd9 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-1.c @@ -27,11 +27,8 @@ int main(void) result); printf("Test PASSED\n"); return PTS_PASS; - } else { - perror("An error occurs"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + perror("An error occurs"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-2.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-2.c index e9a1636..775ec73 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-2.c @@ -27,11 +27,8 @@ int main(void) result); printf("Test PASSED\n"); return PTS_PASS; - } else { - perror("An error occurs"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + perror("An error occurs"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-3.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-3.c index 184ee7f..405c3f3 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-3.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-3.c @@ -31,13 +31,10 @@ int main(void) result); printf("Test PASSED\n"); return PTS_PASS; - } else { - perror("An error occurs"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + perror("An error occurs"); + return PTS_FAIL; } #else int main(void) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-4.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-4.c index b8e7f99..1bfd17e 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-4.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/1-4.c @@ -27,11 +27,8 @@ int main(void) result); printf("Test PASSED\n"); return PTS_PASS; - } else { - perror("An error occurs"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + perror("An error occurs"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/2-1.c index 40cb00d..54a6ab1 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/2-1.c @@ -34,11 +34,8 @@ int main(void) if (errno != EINVAL) { perror("error is not EINVAL"); return PTS_FAIL; - } else { - printf("Unresolved test error\n"); - return PTS_UNRESOLVED; } - printf("This code should not be executed.\n"); + printf("Unresolved test error\n"); return PTS_UNRESOLVED; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/1-1.c index df2963a..3bbcef8 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/1-1.c @@ -29,13 +29,19 @@ int main(void) if (result == 0 && param.sched_priority != -1 && errno == 0) { printf("Test PASSED\n"); return PTS_PASS; - } else if (result != 0) { + } + + if (result != 0) { printf("Return code is not zero.\n"); return PTS_FAIL; - } else if (errno != 0) { + } + + if (errno != 0) { perror("Unexpected error"); return PTS_FAIL; - } else if (param.sched_priority == -1) { + } + + if (param.sched_priority == -1) { printf("The 'sched_priority' member does not change.\n"); return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/2-1.c index c419103..d7658e1 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/2-1.c @@ -35,12 +35,9 @@ int main(void) param0.sched_priority == param1.sched_priority && errno == 0) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Different results between pid == 0 " - "and pid == getpid().\n"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Different results between pid == 0 " + "and pid == getpid().\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/3-1.c index 6e89b0d..378cada 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/3-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/3-1.c @@ -17,7 +17,6 @@ int main(void) { - struct sched_param param; int result = -1; @@ -38,11 +37,8 @@ int main(void) if (result != 0) { printf("returned code is not zero.\n"); return PTS_FAIL; - } else { - perror("Unresolved test error"); - return PTS_UNRESOLVED; } - printf("This code should not be executed.\n"); + perror("Unresolved test error"); return PTS_UNRESOLVED; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_getscheduler/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_getscheduler/1-1.c index d764ffb..7eebaff 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_getscheduler/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_getscheduler/1-1.c @@ -29,15 +29,14 @@ int main(void) if (result0 == result1 && errno == 0) { printf("Test PASSED\n"); return PTS_PASS; - } else if (result0 != result1) { + } + + if (result0 != result1) { printf("Different results between pid == 0 " "and pid == getpid().\n"); return PTS_FAIL; - } else { - perror("Unexpected error"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + perror("Unexpected error"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sem_post/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sem_post/4-1.c index c1902d3..bf18d1b 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sem_post/4-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sem_post/4-1.c @@ -41,10 +41,8 @@ int main(void) sem_close(mysemp); sem_unlink(semname); return PTS_PASS; - } else { - puts("TEST FAILED: value of sem_post is not returning zero"); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + + puts("TEST FAILED: value of sem_post is not returning zero"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_create/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_create/1-1.c index 57f8eb2..0a7db51 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_create/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_create/1-1.c @@ -88,13 +88,10 @@ int main(void) if (abs(tsleft.tv_sec - SLEEPDELTA) <= ACCEPTABLEDELTA) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Timer did not last for correct amount of time\n"); - printf("timer: %d != correct %d\n", - (int)ts.tv_sec - (int)tsleft.tv_sec, TIMERSEC); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Timer did not last for correct amount of time\n"); + printf("timer: %d != correct %d\n", + (int)ts.tv_sec - (int)tsleft.tv_sec, TIMERSEC); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_delete/1-2.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_delete/1-2.c index 769bfc0..43a7c14 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_delete/1-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_delete/1-2.c @@ -58,11 +58,8 @@ int main(void) printf("errno!=EINVAL after a timer_delete()\n"); return PTS_FAIL; } - } else { - printf("timer_settime() did not fail after timer_delete()\n"); - return PTS_FAIL; } - printf("This code should not be executed\n"); - return PTS_UNRESOLVED; + printf("timer_settime() did not fail after timer_delete()\n"); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/1-1.c index c9656de..624d48b 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/1-1.c @@ -109,14 +109,11 @@ int main(void) overruns = timer_getoverrun(tid); printf("Total overruns: %d\n", overruns); - if (1 == madeit) { + if (madeit == 1) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("FAIL: %d signals sent\n", madeit); - return PTS_FAIL; } - printf("UNRESOLVED: This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("FAIL: %d signals sent\n", madeit); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-1.c index 43e88bf..88e152a 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-1.c @@ -83,12 +83,9 @@ int main(void) if (EXPECTEDOVERRUNS == overruns) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("FAIL: %d overruns sent; expected %d\n", - overruns, EXPECTEDOVERRUNS); - return PTS_FAIL; } - printf("UNRESOLVED: This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("FAIL: %d overruns sent; expected %d\n", + overruns, EXPECTEDOVERRUNS); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-3.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-3.c index 0528d4d..96b7d01 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-3.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-3.c @@ -150,12 +150,9 @@ int main(void) if (overruns >= expectedoverruns && overruns < expectedoverruns + fudge) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("FAIL: %d overruns sent; expected %d\n", - overruns, expectedoverruns); - return PTS_FAIL; } - printf("UNRESOLVED: This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("FAIL: %d overruns sent; expected %d\n", + overruns, expectedoverruns); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-1.c index 38728fb..e2f66e5 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-1.c @@ -69,13 +69,10 @@ int main(void) if (delta <= ACCEPTABLEDELTA) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("FAIL: timer_gettime() value !~= timer_settime()\n"); - printf("%d !~= %d\n", (int)itsget.it_value.tv_sec, - (int)itsset.it_value.tv_sec); - return PTS_FAIL; } - printf("This code should not be executed\n"); - return PTS_UNRESOLVED; + printf("FAIL: timer_gettime() value !~= timer_settime()\n"); + printf("%d !~= %d\n", (int)itsget.it_value.tv_sec, + (int)itsset.it_value.tv_sec); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-2.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-2.c index a499232..0c39a6e 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-2.c @@ -76,13 +76,10 @@ int main(void) if (delta <= ACCEPTABLEDELTA) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("FAIL: timer_gettime() value !~= time expected left\n"); - printf("%d !~= %d\n", (int)itsget.it_value.tv_sec, - (int)itsset.it_value.tv_sec - SLEEPSEC); - return PTS_FAIL; } - printf("This code should not be executed\n"); - return PTS_UNRESOLVED; + printf("FAIL: timer_gettime() value !~= time expected left\n"); + printf("%d !~= %d\n", (int)itsget.it_value.tv_sec, + (int)itsset.it_value.tv_sec - SLEEPSEC); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-4.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-4.c index 5ee9f40..1c6a363 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-4.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/1-4.c @@ -103,13 +103,10 @@ int main(void) if (delta <= ACCEPTABLEDELTA) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("FAIL: timer_gettime() value !~= time expected left\n"); - printf("%d !~= %d\n", (int)itsget.it_value.tv_sec, - (int)itsset.it_value.tv_sec - SLEEPSEC); - return PTS_FAIL; } - printf("This code should not be executed\n"); - return PTS_UNRESOLVED; + printf("FAIL: timer_gettime() value !~= time expected left\n"); + printf("%d !~= %d\n", (int)itsget.it_value.tv_sec, + (int)itsset.it_value.tv_sec - SLEEPSEC); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/2-2.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/2-2.c index f4148e0..e5c10c0 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/2-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/2-2.c @@ -63,13 +63,10 @@ int main(void) if (0 == itsget.it_value.tv_sec && 0 == itsget.it_value.tv_nsec) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Test FAILED: tv_sec %d tv_nsec %d\n", - (int)itsget.it_value.tv_sec, - (int)itsget.it_value.tv_nsec); - return PTS_FAIL; } - printf("This code should not be executed\n"); - return PTS_UNRESOLVED; + printf("Test FAILED: tv_sec %d tv_nsec %d\n", + (int)itsget.it_value.tv_sec, + (int)itsget.it_value.tv_nsec); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/3-1.c index 18e8a77..9777256 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/3-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/3-1.c @@ -78,13 +78,10 @@ int main(void) if (delta <= ACCEPTABLEDELTA) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("FAIL: timer_gettime() value !~= timer_settime()\n"); - printf("%d !~= %d\n", (int)itsget.it_value.tv_sec, - (int)itsset.it_value.tv_sec); - return PTS_FAIL; } - printf("This code should not be executed\n"); - return PTS_UNRESOLVED; + printf("FAIL: timer_gettime() value !~= timer_settime()\n"); + printf("%d !~= %d\n", (int)itsget.it_value.tv_sec, + (int)itsset.it_value.tv_sec); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/1-1.c index fc1e644..c8e0a04 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/1-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/1-1.c @@ -90,13 +90,10 @@ int main(void) if (abs(tsleft.tv_sec - SLEEPDELTA) <= ACCEPTABLEDELTA) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Timer did not last for correct amount of time\n"); - printf("timer: %d != correct %d\n", - (int)ts.tv_sec - (int)tsleft.tv_sec, TIMERSEC); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Timer did not last for correct amount of time\n"); + printf("timer: %d != correct %d\n", + (int)ts.tv_sec - (int)tsleft.tv_sec, TIMERSEC); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/1-2.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/1-2.c index 24c02eb..9ba0612 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/1-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/1-2.c @@ -105,11 +105,8 @@ int main(void) if (failure) { printf("At least one test FAILED\n"); return PTS_FAIL; - } else { - printf("All tests PASSED\n"); - return PTS_PASS; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("All tests PASSED\n"); + return PTS_PASS; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/13-1.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/13-1.c index 3596305..31cd56f 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/13-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/13-1.c @@ -98,11 +98,8 @@ int main(void) if (failure) { printf("At least one test FAILED\n"); return PTS_FAIL; - } else { - printf("All tests PASSED\n"); - return PTS_PASS; } - printf("This code could not be executed.\n"); - return PTS_UNRESOLVED; + printf("All tests PASSED\n"); + return PTS_PASS; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/5-1.c index 03ea922..1151ed4 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/5-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/5-1.c @@ -92,13 +92,10 @@ int main(void) if (abs(tsleft.tv_sec - SLEEPDELTA) <= ACCEPTABLEDELTA) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Timer did not last for correct amount of time\n"); - printf("timer: %d != correct %d\n", - (int)ts.tv_sec - (int)tsleft.tv_sec, TIMERSEC); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Timer did not last for correct amount of time\n"); + printf("timer: %d != correct %d\n", + (int)ts.tv_sec - (int)tsleft.tv_sec, TIMERSEC); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-1.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-1.c index 0add2d2..e8ce8c2 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-1.c @@ -51,15 +51,12 @@ int main(void) (0 == oits.it_interval.tv_sec) && (0 == oits.it_interval.tv_nsec)) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Test FAILED: value: tv_sec %d tv_nsec %d\n", - (int)oits.it_value.tv_sec, (int)oits.it_value.tv_nsec); - printf("Test FAILED: interval: tv_sec %d tv_nsec %d\n", - (int)oits.it_interval.tv_sec, - (int)oits.it_interval.tv_nsec); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Test FAILED: value: tv_sec %d tv_nsec %d\n", + (int)oits.it_value.tv_sec, (int)oits.it_value.tv_nsec); + printf("Test FAILED: interval: tv_sec %d tv_nsec %d\n", + (int)oits.it_interval.tv_sec, + (int)oits.it_interval.tv_nsec); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-2.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-2.c index b66ea21..0493de2 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-2.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-2.c @@ -74,16 +74,13 @@ int main(void) (0 == oits.it_interval.tv_sec) && (0 == oits.it_interval.tv_nsec)) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Test FAILED: value: tv_sec %d tv_nsec %d\n", - (int)oits.it_value.tv_sec, (int)oits.it_value.tv_nsec); - - printf("Test FAILED: interval: tv_sec %d tv_nsec %d\n", - (int)oits.it_interval.tv_sec, - (int)oits.it_interval.tv_nsec); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Test FAILED: value: tv_sec %d tv_nsec %d\n", + (int)oits.it_value.tv_sec, (int)oits.it_value.tv_nsec); + + printf("Test FAILED: interval: tv_sec %d tv_nsec %d\n", + (int)oits.it_interval.tv_sec, + (int)oits.it_interval.tv_nsec); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-3.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-3.c index c34938f..f512404 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-3.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-3.c @@ -62,12 +62,9 @@ int main(void) if (abs(oits.it_value.tv_sec - TIMELEFT) <= ACCEPTABLEDELTA) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Test FAILED: time left %d oits.it_value.tv_sec %d\n", - TIMELEFT, (int)oits.it_value.tv_sec); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Test FAILED: time left %d oits.it_value.tv_sec %d\n", + TIMELEFT, (int)oits.it_value.tv_sec); + return PTS_FAIL; } diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-4.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-4.c index ad4ecbf..cdf4612 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-4.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/8-4.c @@ -60,12 +60,9 @@ int main(void) if (RELOADVAL == oits.it_interval.tv_sec) { printf("Test PASSED\n"); return PTS_PASS; - } else { - printf("Test FAILED: correct %d oits.it_interval %d\n", - RELOADVAL, (int)oits.it_interval.tv_sec); - return PTS_FAIL; } - printf("This code should not be executed.\n"); - return PTS_UNRESOLVED; + printf("Test FAILED: correct %d oits.it_interval %d\n", + RELOADVAL, (int)oits.it_interval.tv_sec); + return PTS_FAIL; } hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-14 09:51:09
|
The branch, master, has been updated via 6f3147f01229f3bb953202cde828d35e0d2bcb8a (commit) from e5c18eaa4b8f9f73516eaf68213d6beee80cf3b5 (commit) - Log ----------------------------------------------------------------- commit 6f3147f01229f3bb953202cde828d35e0d2bcb8a Author: Riku Voipio <rik...@li...> Date: Mon Oct 14 11:50:28 2013 +0300 power_management: add TCID get_sched_values.c uses interfaces provided by -lltp which need TCID defined. Not sure how this built successfully before. [v2] correct TCID to an unique one Cc: Wanlong Gao <gao...@cn...> Signed-off-by: Riku Voipio <rik...@li...> Reviewed-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: .../kernel/power_management/get_sched_values.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/testcases/kernel/power_management/get_sched_values.c b/testcases/kernel/power_management/get_sched_values.c index 08260d5..328e682 100644 --- a/testcases/kernel/power_management/get_sched_values.c +++ b/testcases/kernel/power_management/get_sched_values.c @@ -17,6 +17,8 @@ #include <stdio.h> #include "test.h" +const char *TCID = "get_sched_values"; + int get_supp_sched_mc(void) { if (tst_kvercmp(2, 6, 29) < 0) hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-14 05:51:14
|
The branch, master, has been updated via e5c18eaa4b8f9f73516eaf68213d6beee80cf3b5 (commit) via b217b3ead51fa07d61455fb868db97ae0c732b02 (commit) from 2a63f690cf3361152bda1aa687f8c754b514b405 (commit) - Log ----------------------------------------------------------------- commit e5c18eaa4b8f9f73516eaf68213d6beee80cf3b5 Author: Riku Voipio <rik...@li...> Date: Fri Oct 11 12:09:08 2013 +0300 Remove bogus Aarch64 system call numbers Aarch64 build fails with: cacheflush01.c:52:26: fatal error: asm/cachectl.h: No such file or directory #include <asm/cachectl.h> This is caused by bogus definitions of cacheflush and set_tls, which are private 32bit ARM system calls. These should not be used on native Aarch64 binaries. If they need to be tested, it is better done using ltp compiled for 32bit ARM. Signed-off-by: Riku Voipio <rik...@li...> Signed-off-by: Mike Frysinger <va...@ge...> commit b217b3ead51fa07d61455fb868db97ae0c732b02 Author: Stanislav Kholmanskikh <sta...@or...> Date: Wed Oct 9 17:11:09 2013 +0400 tst_kvercmp2: Criteria for Oracle Linux UEK kernels Signed-off-by: Stanislav Kholmanskikh <sta...@or...> Acked-by: Wanlong Gao <gao...@cn...> Signed-off-by: Mike Frysinger <va...@ge...> ----------------------------------------------------------------------- Summary of changes: lib/tst_kvercmp.c | 6 +++++- testcases/kernel/include/aarch64.in | 2 -- testcases/kernel/include/linux_syscall_numbers.h | 9 --------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/tst_kvercmp.c b/lib/tst_kvercmp.c index a703c47..a950120 100644 --- a/lib/tst_kvercmp.c +++ b/lib/tst_kvercmp.c @@ -95,8 +95,12 @@ int tst_kvercmp2(int r1, int r2, int r3, struct tst_kern_exv *vers) uname(&uval); kver = uval.release; - if (strstr(kver, ".el5")) { + if (strstr(kver, ".el5uek")) { + cur_dist_name = "OL5UEK"; + } else if (strstr(kver, ".el5")) { cur_dist_name = "RHEL5"; + } else if (strstr(kver, ".el6uek")) { + cur_dist_name = "OL6UEK"; } else if (strstr(kver, ".el6")) { cur_dist_name = "RHEL6"; } diff --git a/testcases/kernel/include/aarch64.in b/testcases/kernel/include/aarch64.in index a845be0..ceb67c6 100644 --- a/testcases/kernel/include/aarch64.in +++ b/testcases/kernel/include/aarch64.in @@ -253,5 +253,3 @@ clock_adjtime 266 syncfs 267 setns 268 sendmmsg 269 -cacheflush 0x1002 -set_tls 0x1005 diff --git a/testcases/kernel/include/linux_syscall_numbers.h b/testcases/kernel/include/linux_syscall_numbers.h index 38931cf..03664ce 100644 --- a/testcases/kernel/include/linux_syscall_numbers.h +++ b/testcases/kernel/include/linux_syscall_numbers.h @@ -801,12 +801,6 @@ # ifndef __NR_sendmmsg # define __NR_sendmmsg 269 # endif -# ifndef __NR_cacheflush -# define __NR_cacheflush 0x1002 -# endif -# ifndef __NR_set_tls -# define __NR_set_tls 0x1005 -# endif #endif @@ -12754,9 +12748,6 @@ # ifndef __NR_settimeofday # define __NR_settimeofday __LTP__NR_INVALID_SYSCALL # endif -# ifndef __NR_set_tls -# define __NR_set_tls __LTP__NR_INVALID_SYSCALL -# endif # ifndef __NR_setuid # define __NR_setuid __LTP__NR_INVALID_SYSCALL # endif hooks/post-receive -- ltp |
From: Mike F. <su...@li...> - 2013-10-14 05:37:14
|
The branch, master, has been updated via 2a63f690cf3361152bda1aa687f8c754b514b405 (commit) from 858757dd873d4292406749e8affa46aa704888b6 (commit) - Log ----------------------------------------------------------------- commit 2a63f690cf3361152bda1aa687f8c754b514b405 Author: Maxim Uvarov <max...@li...> Date: Wed Oct 9 18:11:05 2013 +0400 syslog-lib.sh bash posix compliance /opt/ltp/testcases/bin/syslog02: 69: [: syslog-ng: unexpected operator + [ syslog-ng == syslog-ng ] Accoding to: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html [ STRING1 == STRING2 ] True if the strings are equal. "=" may be used instead of "==" for strict POSIX compliance. Because of busybox and other bash like shells look for posix syntax make it so. Signed-off-by: Maxim Uvarov <max...@li...> Reviewed-by: Wanlong Gao <gao...@cn...> Signed-off-by: Mike Frysinger <va...@ge...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/syslog/syslog-lib.sh | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/testcases/kernel/syscalls/syslog/syslog-lib.sh b/testcases/kernel/syscalls/syslog/syslog-lib.sh index 9c5d7f1..b656515 100755 --- a/testcases/kernel/syscalls/syslog/syslog-lib.sh +++ b/testcases/kernel/syscalls/syslog/syslog-lib.sh @@ -65,11 +65,11 @@ setup() tst_resm TBROK "Testing is terminating due to a signal" cleanup 1' $TRAP_SIGS || exit 1 - if [ "$SYSLOG_DAEMON" == "syslog" ]; then + if [ "$SYSLOG_DAEMON" = "syslog" ]; then CONFIG_FILE="/etc/syslog.conf" - elif [ "$SYSLOG_DAEMON" == "syslog-ng" ]; then + elif [ "$SYSLOG_DAEMON" = "syslog-ng" ]; then CONFIG_FILE="/etc/syslog-ng/syslog-ng.conf" - elif [ "$SYSLOG_DAEMON" == "rsyslog" ]; then + elif [ "$SYSLOG_DAEMON" = "rsyslog" ]; then CONFIG_FILE="/etc/rsyslog.conf" RSYSLOG_CONFIG='$ModLoad imuxsock.so' else hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-02 10:51:18
|
The branch, master, has been updated via 858757dd873d4292406749e8affa46aa704888b6 (commit) via 427cbb3a8e620a5ce631fd6e15e5c98ddf5e0c69 (commit) via 4970a2f345c5954882f72d4aaba2172ce7c3f39c (commit) via e0470392a7dba49eed2f66cda97c12d3cd703a15 (commit) from 971bcd7e51e4e6f94a58374f9b3cd22e53e7e53e (commit) - Log ----------------------------------------------------------------- commit 858757dd873d4292406749e8affa46aa704888b6 Author: Cyril Hrubis <ch...@su...> Date: Wed Oct 2 12:36:28 2013 +0200 kernel/firmware: Make use of modules.mk Signed-off-by: Cyril Hrubis <ch...@su...> commit 427cbb3a8e620a5ce631fd6e15e5c98ddf5e0c69 Author: Alexey Kodanev <ale...@or...> Date: Wed Sep 11 14:55:27 2013 +0400 device-drivers: block: enable build and run Signed-off-by: Alexey Kodanev <ale...@or...> Reviewed-by: Cyril Hrubis <ch...@su...> commit 4970a2f345c5954882f72d4aaba2172ce7c3f39c Author: Alexey Kodanev <ale...@or...> Date: Wed Oct 2 13:23:50 2013 +0400 device-drivers: block: fixes Fixed test-cases behavior: major number greater than 255 is valid, empty device name is valid. Added test-cases results and sysfs files. Added user-space program which checks each test-case result. Added command line parameter 'a': run all test-cases. Signed-off-by: Alexey Kodanev <ale...@or...> Reviewed-by: Cyril Hrubis <ch...@su...> commit e0470392a7dba49eed2f66cda97c12d3cd703a15 Author: Alexey Kodanev <ale...@or...> Date: Wed Sep 11 14:31:47 2013 +0400 device-drivers: block: rename test files and remove run.sh Signed-off-by: Alexey Kodanev <ale...@or...> Reviewed-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: runtest/kernel_misc | 1 + testcases/kernel/device-drivers/Makefile | 3 +- testcases/kernel/device-drivers/block/Makefile | 20 + testcases/kernel/device-drivers/block/README | 23 + .../block/block_dev_kernel/.gitignore | 7 + .../device-drivers/block/block_dev_kernel/Makefile | 33 ++ .../block/block_dev_kernel/ltp_block_dev.c | 428 ++++++++++++++++++++ .../test_genhd.c | 0 .../device-drivers/block/block_dev_user/.gitignore | 1 + .../device-drivers/block/block_dev_user/Makefile | 20 + .../block/block_dev_user/block_dev.c | 110 +++++ .../device-drivers/block/kernel_space/Makefile | 24 -- .../device-drivers/block/kernel_space/README | 27 -- .../device-drivers/block/kernel_space/run.sh | 47 --- .../device-drivers/block/kernel_space/test_block.c | 310 -------------- testcases/kernel/firmware/Makefile | 24 -- testcases/kernel/firmware/fw_load_kernel/Makefile | 13 +- 17 files changed, 648 insertions(+), 443 deletions(-) create mode 100644 testcases/kernel/device-drivers/block/Makefile create mode 100644 testcases/kernel/device-drivers/block/README create mode 100644 testcases/kernel/device-drivers/block/block_dev_kernel/.gitignore create mode 100644 testcases/kernel/device-drivers/block/block_dev_kernel/Makefile create mode 100644 testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c rename testcases/kernel/device-drivers/block/{kernel_space => block_dev_kernel}/test_genhd.c (100%) create mode 100644 testcases/kernel/device-drivers/block/block_dev_user/.gitignore create mode 100644 testcases/kernel/device-drivers/block/block_dev_user/Makefile create mode 100644 testcases/kernel/device-drivers/block/block_dev_user/block_dev.c delete mode 100644 testcases/kernel/device-drivers/block/kernel_space/Makefile delete mode 100644 testcases/kernel/device-drivers/block/kernel_space/README delete mode 100755 testcases/kernel/device-drivers/block/kernel_space/run.sh delete mode 100644 testcases/kernel/device-drivers/block/kernel_space/test_block.c diff --git a/runtest/kernel_misc b/runtest/kernel_misc index 29071b3..654e217 100644 --- a/runtest/kernel_misc +++ b/runtest/kernel_misc @@ -1,3 +1,4 @@ kmsg01 kmsg01 fw_load fw_load rtc01 rtc01 +block_dev block_dev diff --git a/testcases/kernel/device-drivers/Makefile b/testcases/kernel/device-drivers/Makefile index 62005c2..73755db 100644 --- a/testcases/kernel/device-drivers/Makefile +++ b/testcases/kernel/device-drivers/Makefile @@ -18,6 +18,7 @@ top_srcdir ?= ../../.. include $(top_srcdir)/include/mk/env_pre.mk -SUBDIRS := rtc \ +SUBDIRS := block \ + rtc \ include $(top_srcdir)/include/mk/generic_trunk_target.mk diff --git a/testcases/kernel/device-drivers/block/Makefile b/testcases/kernel/device-drivers/block/Makefile new file mode 100644 index 0000000..b3bb5aa --- /dev/null +++ b/testcases/kernel/device-drivers/block/Makefile @@ -0,0 +1,20 @@ +# Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. +# +# 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 would 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 the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/env_pre.mk +include $(top_srcdir)/include/mk/generic_trunk_target.mk diff --git a/testcases/kernel/device-drivers/block/README b/testcases/kernel/device-drivers/block/README new file mode 100644 index 0000000..812436b --- /dev/null +++ b/testcases/kernel/device-drivers/block/README @@ -0,0 +1,23 @@ + +Module under test: linux/block/genhd.c + + Function | Declared in | Tested in + -----------------------------+---------------+--------------- + register_blkdev() | linux/fs.h | ltp_block_dev.c + unregister_blkdev() | linux/fs.h | ltp_block_dev.c + blk_register_region() | linux/genhd.h | + blk_unregister_region() | linux/genhd.h | + add_disk() | linux/genhd.h | + del_gendisk() | linux/genhd.h | test_genhd.c + blk_lookup_devt() | linux/genhd.h | + alloc_disk() | linux/genhd.h | test_genhd.c + alloc_disk_node() | linux/genhd.h | + get_disk() | linux/genhd.h | + put_disk() | linux/genhd.h | + set_device_ro() | linux/genhd.h | + set_disk_ro() | linux/genhd.h | + bdev_read_only() | linux/fs.h | + invalidate_partition() | linux/fs.h | + +For possible test results please see "A POSIX conforming test framework" at +http://www.gnu.org/software/dejagnu/manual/x47.html#posix diff --git a/testcases/kernel/device-drivers/block/block_dev_kernel/.gitignore b/testcases/kernel/device-drivers/block/block_dev_kernel/.gitignore new file mode 100644 index 0000000..3beebe1 --- /dev/null +++ b/testcases/kernel/device-drivers/block/block_dev_kernel/.gitignore @@ -0,0 +1,7 @@ +/ltp_block_dev.ko +/*.mod.c +/modules.order +/.tmp_versions +/.*.ko +/.*.cmd +/Module.symvers diff --git a/testcases/kernel/device-drivers/block/block_dev_kernel/Makefile b/testcases/kernel/device-drivers/block/block_dev_kernel/Makefile new file mode 100644 index 0000000..1013305 --- /dev/null +++ b/testcases/kernel/device-drivers/block/block_dev_kernel/Makefile @@ -0,0 +1,33 @@ +# Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. +# +# 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 would 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 the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +ifneq ($(KERNELRELEASE),) + +obj-m := ltp_block_dev.o + +else + +top_srcdir ?= ../../../../.. +include $(top_srcdir)/include/mk/env_pre.mk + +REQ_VERSION_MAJOR := 2 +REQ_VERSION_PATCH := 6 +MAKE_TARGETS := ltp_block_dev.ko + +include $(top_srcdir)/include/mk/module.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk + +endif diff --git a/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c b/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c new file mode 100644 index 0000000..d573085 --- /dev/null +++ b/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c @@ -0,0 +1,428 @@ +/* + * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. + * + * 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 would 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 the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Only those functions are tested here which are declared in <linux/fs.h> + * + * Changes: + * 16 Jan 2009 0.2 Added "tc" parameter to run test cases separately + * 11 Jan 2009 0.1 First release + */ + +#include <linux/module.h> +#include <linux/device.h> +#include <linux/fs.h> + +MODULE_AUTHOR("Márton Németh <nm...@fr...>"); +MODULE_AUTHOR("Copyright (c) 2013 Oracle and/or its affiliates"); +MODULE_DESCRIPTION("Test block drivers"); +MODULE_LICENSE("GPL"); + +#define BLK_DEV_NAME "ltp_block_dev" +#define MAX_MAJOR 255 + +#define prk_err(fmt, ...) \ + pr_err(BLK_DEV_NAME ": " fmt, ##__VA_ARGS__) +#define prk_info(fmt, ...) \ + pr_info(BLK_DEV_NAME ": " fmt, ##__VA_ARGS__) +#define prk_debug(fmt, ...) \ + pr_debug(BLK_DEV_NAME ": " fmt, ##__VA_ARGS__) + +/* + * Analysis of "int register_blkdev(unsigned int major, const char *name)" + * + * Equivalence classes: + * + * Parameter | Values | Valid? | Covered in + * -----------+--------------------------+---------+------------- + * major | [0] | valid | tc01, tc02 + * |--------------------------+---------+------------- + * | [1..255] | valid | tc03 + * |--------------------------+---------+------------- + * | [256..UINT_MAX] | valid | tc04, tc05 + * -----------+--------------------------+---------+------------- + * name | [valid pointer to a zero | | + * | terminated string] | valid | tc01, tc02 + * |--------------------------+---------+------------- + * | [valid pointer to a zero | | + * | length zero terminated | valid | tc06 + * | string] | | + * |--------------------------+---------+------------- + * | [NULL] | invalid | tc08, tc09 + * -----------+--------------------------+---------+------------- + * + */ + +#define result_str(pass) ((pass == 0) ? ("FAIL") : ("PASS")) + +/* + * bit mask for each test-case, + * if test is passed, bit will be set to 1 + */ +static int test_result; + +static void device_release(struct device *dev) +{ + prk_info("device released\n"); +} + +static struct device tdev = { + .init_name = BLK_DEV_NAME, + .release = device_release, +}; + +static int tc01(void) +{ + int major1, major2; + int pass = 1; + + prk_info("Test Case 1: register_blkdev() with auto allocating " + "major numbers (major=0)\n"); + + major1 = register_blkdev(0, BLK_DEV_NAME); + prk_debug("major1 = %i\n", major1); + + major2 = register_blkdev(0, BLK_DEV_NAME); + prk_debug("major2 = %i\n", major2); + + if (major1 >= 0) { + unregister_blkdev(major1, BLK_DEV_NAME); + } else { + pass = 0; + prk_debug("1st call to register_blkdev() failed, error %i\n", + major1); + } + + if (major2 >= 0) { + unregister_blkdev(major2, BLK_DEV_NAME); + } else { + pass = 0; + prk_debug("2nd call to register_blkdev() failed, error %i\n", + major2); + } + + prk_info("Test Case Result: %s\n", result_str(pass)); + return pass; +} + +static int tc02(void) +{ + int major[MAX_MAJOR + 1]; + int i, pass = 2; + + /* Try to allocate block devices until all major numbers are used. + * After this register_blkdev() should return -EBUSY + */ + + prk_info("Test Case 2: stress test of register_blkdev() " + "with auto allocating major numbers (major=0)\n"); + + memset(major, 0, sizeof(major)); + + for (i = 0; i < sizeof(major) / sizeof(*major); ++i) { + major[i] = register_blkdev(0, BLK_DEV_NAME); + prk_debug("major[%i] = %i\n", i, major[i]); + + if (major[i] == -EBUSY) { + prk_info("device is busy, register_blkdev() ret %i\n", + major[i]); + } else if (major[i] < 0) { + prk_debug("register_blkdev() failed with error %i\n", + major[i]); + pass = 0; + } + } + + for (i = 0; i < sizeof(major) / sizeof(*major); ++i) { + if (major[i] >= 0) + unregister_blkdev(major[i], BLK_DEV_NAME); + } + + prk_info("Test Case Result: %s\n", result_str(pass)); + return pass; +} + +static int tc03(void) +{ + int major, major2, major3; + int pass = 4; + + prk_info("Test Case 3: register_blkdev() with major != 0\n"); + + /* autosearch for a free major number */ + major = register_blkdev(0, BLK_DEV_NAME); + prk_debug("major = %i\n", major); + + if (major > 0) { + unregister_blkdev(major, BLK_DEV_NAME); + + /* expected to return 0 */ + major2 = register_blkdev(major, BLK_DEV_NAME); + + /* this call has to fail with EBUSY return value */ + major3 = register_blkdev(major, BLK_DEV_NAME); + + if (major2 == 0) { + unregister_blkdev(major, BLK_DEV_NAME); + } else { + pass = 0; + prk_debug("1st call to register_blkdev() with major=%i " + "failed with error %i\n", major, major2); + } + + if (major3 == 0) { + unregister_blkdev(major, BLK_DEV_NAME); + pass = 0; + } else { + if (major3 != -EBUSY) + pass = 0; + prk_debug("2nd call to register_blkdev() with major=%i " + "failed with error %i\n", major, major3); + } + + } else { + pass = 0; + prk_debug("register_blkdev() failed with error %i\n", major); + } + + prk_info("Test Case Result: %s\n", result_str(pass)); + return pass; +} + +static int tc04(void) +{ + int major, pass = 8; + + prk_info("Test Case 4: register_blkdev() with major=256\n"); + + major = register_blkdev(256, BLK_DEV_NAME); + prk_debug("major = %i\n", major); + + if (major == 0) { + unregister_blkdev(256, BLK_DEV_NAME); + } else { + pass = 0; + prk_debug("register_blkdev() failed with error %i\n", major); + } + + prk_info("Test Case Result: %s\n", result_str(pass)); + return pass; +} + +static int tc05(void) +{ + int major, pass = 16; + + prk_info("Test Case 5: register_blkdev() with major=%u\n", UINT_MAX); + + major = register_blkdev(UINT_MAX, BLK_DEV_NAME); + prk_debug("major = %i\n", major); + + if (major == 0) { + unregister_blkdev(UINT_MAX, BLK_DEV_NAME); + } else { + prk_debug("reg blkdev with major %d failed with error %i\n", + UINT_MAX, major); + pass = 0; + } + + prk_info("Test Case Result: %s\n", result_str(pass)); + return pass; +} + +static int tc06(void) +{ + int major, pass = 32; + + prk_info("Test Case 6: register_blkdev() with name=\"\"\n"); + + major = register_blkdev(0, ""); + prk_debug("major = %i\n", major); + + if (major >= 0) { + unregister_blkdev(major, ""); + } else { + pass = 0; + prk_debug("register_blkdev() failed with error %i\n", major); + } + + prk_info("Test Case Result: %s\n", result_str(pass)); + return pass; +} + +static int tc07(void) +{ + int major, pass = 64; + + prk_info("Test Case 7: unregister_blkdev() with major=0\n"); + + major = register_blkdev(0, BLK_DEV_NAME); + prk_debug("major = %i\n", major); + + if (major >= 0) { + prk_debug("calling unregister_blkdev() with major=0\n"); + unregister_blkdev(0, BLK_DEV_NAME); + prk_debug("calling unregister_blkdev() with major=%i\n", major); + unregister_blkdev(major, BLK_DEV_NAME); + } else { + pass = 0; + prk_debug("register_blkdev() failed with error %i\n", major); + } + + prk_info("Test Case Result: %s\n", result_str(pass)); + return pass; +} + +static int tc08(void) +{ + int major, pass = 128; + + prk_info("Test Case 8: register_blkdev() with name=NULL\n"); + + /* should fail with -EINVAL */ + major = register_blkdev(0, NULL); + prk_debug("major = %i\n", major); + + if (major >= 0) { + unregister_blkdev(major, NULL); + pass = 0; + } else { + prk_debug("register_blkdev() failed with error %i\n", major); + } + + prk_info("Test Case Result: %s\n", result_str(pass)); + return pass; +} + +static int tc09(void) +{ + int major, pass = 256; + + prk_info("Test Case 9: unregister_blkdev() with name=NULL\n"); + + major = register_blkdev(0, BLK_DEV_NAME); + prk_debug("major = %i\n", major); + + if (major >= 0) { + /* kernel should silently ignore this */ + unregister_blkdev(major, NULL); + unregister_blkdev(major, BLK_DEV_NAME); + } else { + pass = 0; + prk_debug("register_blkdev() failed with error %i\n", major); + } + + prk_info("Test Case Result: %s\n", result_str(pass)); + return pass; +} + +/* print test result to sysfs file */ +static ssize_t sys_result(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return scnprintf(buf, PAGE_SIZE, "%d\n", test_result); +} +static DEVICE_ATTR(result, S_IRUSR, sys_result, NULL); + +/* + * get test-case number and run it + */ +static ssize_t sys_tcase(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int tc = 0; + sscanf(buf, "%d", &tc); + if (tc < 0 || tc > 9) { + prk_err(": Unexpected test-case number '%d'", tc); + return count; + } + + test_result = 0; + + if (tc == 0 || tc == 1) + test_result |= tc01(); + + if (tc == 0 || tc == 2) + test_result |= tc02(); + + if (tc == 0 || tc == 3) + test_result |= tc03(); + + if (tc == 0 || tc == 4) + test_result |= tc04(); + + if (tc == 0 || tc == 5) + test_result |= tc05(); + + if (tc == 0 || tc == 6) + test_result |= tc06(); + + if (tc == 0 || tc == 7) + test_result |= tc07(); + + if (tc == 0 || tc == 8) + test_result |= tc08(); + + if (tc == 0 || tc == 9) + test_result |= tc09(); + + return count; +} +static DEVICE_ATTR(tcase, S_IWUSR, NULL, sys_tcase); + +static int test_init_module(void) +{ + int err = 0; + prk_info("Starting module\n"); + + err = device_register(&tdev); + if (err) { + prk_err("Unable to register device\n"); + goto err0; + } + prk_info("device registered\n"); + + err = device_create_file(&tdev, &dev_attr_result); + if (err) { + prk_err("Can't create sysfs file 'result'\n"); + goto err1; + } + + err = device_create_file(&tdev, &dev_attr_tcase); + if (err) { + prk_err(": Can't create sysfs file 'tc'\n"); + goto err2; + } + + return 0; + +err2: + device_remove_file(&tdev, &dev_attr_result); +err1: + device_unregister(&tdev); +err0: + return err; +} +module_init(test_init_module); + +static void test_exit_module(void) +{ + prk_debug("Unloading module\n"); + device_remove_file(&tdev, &dev_attr_result); + device_remove_file(&tdev, &dev_attr_tcase); + device_unregister(&tdev); +} +module_exit(test_exit_module); diff --git a/testcases/kernel/device-drivers/block/kernel_space/test_genhd.c b/testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c similarity index 100% rename from testcases/kernel/device-drivers/block/kernel_space/test_genhd.c rename to testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c diff --git a/testcases/kernel/device-drivers/block/block_dev_user/.gitignore b/testcases/kernel/device-drivers/block/block_dev_user/.gitignore new file mode 100644 index 0000000..4034ce5 --- /dev/null +++ b/testcases/kernel/device-drivers/block/block_dev_user/.gitignore @@ -0,0 +1 @@ +/block_dev diff --git a/testcases/kernel/device-drivers/block/block_dev_user/Makefile b/testcases/kernel/device-drivers/block/block_dev_user/Makefile new file mode 100644 index 0000000..6ba3465 --- /dev/null +++ b/testcases/kernel/device-drivers/block/block_dev_user/Makefile @@ -0,0 +1,20 @@ +# Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. +# +# 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 would 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 the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +top_srcdir ?= ../../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/device-drivers/block/block_dev_user/block_dev.c b/testcases/kernel/device-drivers/block/block_dev_user/block_dev.c new file mode 100644 index 0000000..8f26f3c --- /dev/null +++ b/testcases/kernel/device-drivers/block/block_dev_user/block_dev.c @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. + * + * 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 would 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 the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: Alexey Kodanev <ale...@or...> + * + * Test checks block device kernel API. + */ + +#define _GNU_SOURCE +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#include "test.h" +#include "usctest.h" +#include "safe_macros.h" +#include "tst_module.h" + +char *TCID = "block_dev"; +int TST_TOTAL = 9; + +static const char module_name[] = "ltp_block_dev.ko"; +static const char dev_result[] = "/sys/devices/ltp_block_dev/result"; +static const char dev_tcase[] = "/sys/devices/ltp_block_dev/tcase"; +static int module_loaded; + +static int run_all_testcases; +static const option_t options[] = { + {"a", &run_all_testcases, NULL}, + {NULL, NULL, NULL} +}; + +static void cleanup(void) +{ + if (module_loaded) + tst_module_unload(NULL, module_name); + + TEST_CLEANUP; +} + +static void help(void) +{ + printf(" -a Run all test-cases (can crash the kernel)\n"); +} + +void setup(int argc, char *argv[]) +{ + char *msg; + msg = parse_opts(argc, argv, options, help); + if (msg != NULL) + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); + + tst_require_root(NULL); + + if (tst_kvercmp(2, 6, 0) < 0) { + tst_brkm(TCONF, NULL, + "Test must be run with kernel 2.6 or newer"); + } + + tst_sig(FORK, DEF_HANDLER, cleanup); +} + +static void test_run(void) +{ + int off = 0; + /* + * test-cases #8 and #9 can crash the kernel. + * We have to wait for kernel fix where register_blkdev() & + * unregister_blkdev() checks the input device name parameter + * against NULL pointer. + */ + if (!run_all_testcases) + off = 2; + + tst_module_load(cleanup, module_name, NULL); + module_loaded = 1; + + int i, pass = 0; + for (i = 0; i < TST_TOTAL - off; ++i) { + SAFE_FILE_PRINTF(cleanup, dev_tcase, "%d", i + 1); + SAFE_FILE_SCANF(cleanup, dev_result, "%d", &pass); + tst_resm((pass) ? TPASS : TFAIL, "Test-case '%d'", i + 1); + } +} + +int main(int argc, char *argv[]) +{ + setup(argc, argv); + + test_run(); + + cleanup(); + + tst_exit(); +} diff --git a/testcases/kernel/device-drivers/block/kernel_space/Makefile b/testcases/kernel/device-drivers/block/kernel_space/Makefile deleted file mode 100644 index 10f33a7..0000000 --- a/testcases/kernel/device-drivers/block/kernel_space/Makefile +++ /dev/null @@ -1,24 +0,0 @@ - -EXTRA_CFLAGS += -Wall -W -Wno-unused-parameter - -ifneq ($(KERNELRELEASE),) - -obj-m := test_block.o test_genhd.o -else -KDIR := /lib/modules/$(shell uname -r)/build -PWD := $(shell pwd) - -modules: - $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules - -clean: - $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean - rm -f modules.order - -help: - $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) help - -modules_install: - $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules_install - -endif diff --git a/testcases/kernel/device-drivers/block/kernel_space/README b/testcases/kernel/device-drivers/block/kernel_space/README deleted file mode 100644 index 6833efd..0000000 --- a/testcases/kernel/device-drivers/block/kernel_space/README +++ /dev/null @@ -1,27 +0,0 @@ - -Module under test: linux/block/genhd.c - - Function | Declared in | Tested in - -----------------------------+---------------+--------------- - register_blkdev() | linux/fs.h | test_blkdev.c - unregister_blkdev() | linux/fs.h | test_blkdev.c - blk_register_region() | linux/genhd.h | - blk_unregister_region() | linux/genhd.h | - add_disk() | linux/genhd.h | - del_gendisk() | linux/genhd.h | test_genhd.c - blk_lookup_devt() | linux/genhd.h | - alloc_disk() | linux/genhd.h | test_genhd.c - alloc_disk_node() | linux/genhd.h | - get_disk() | linux/genhd.h | - put_disk() | linux/genhd.h | - set_device_ro() | linux/genhd.h | - set_disk_ro() | linux/genhd.h | - bdev_read_only() | linux/fs.h | - invalidate_partition() | linux/fs.h | - -For possible test results please see "A POSIX conforming test framework" at -http://www.gnu.org/software/dejagnu/manual/x47.html#posix - -TODO ----- - - Automatically evaluate test results diff --git a/testcases/kernel/device-drivers/block/kernel_space/run.sh b/testcases/kernel/device-drivers/block/kernel_space/run.sh deleted file mode 100755 index 9044453..0000000 --- a/testcases/kernel/device-drivers/block/kernel_space/run.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh - -# Tell the system to flush write buffers in order to minimize data loss in -# case of a crash. -sync - -echo Running Test Cases of "block" testsuite one by one. -echo The test results are printed to "dmesg". -echo - -# -# Valid test cases (should run stable) -# -echo Test Case 1 -insmod ./test_block.ko tc=1 -rmmod test_block - -echo Test Case 2 -insmod ./test_block.ko tc=2 -rmmod test_block - -echo Test Case 5 -insmod ./test_block.ko tc=5 -rmmod test_block - -# -# Invalid testcases (more probable to crash the module under test) -# -echo Test Case 3 -insmod ./test_block.ko tc=3 -rmmod test_block - -echo Test Case 4 -insmod ./test_block.ko tc=4 -rmmod test_block - -echo Test Case 6 -insmod ./test_block.ko tc=6 -rmmod test_block - -echo Test Case 7 -insmod ./test_block.ko tc=7 -rmmod test_block - -echo Test Case 10 -insmod ./test_block.ko tc=10 -rmmod test_block diff --git a/testcases/kernel/device-drivers/block/kernel_space/test_block.c b/testcases/kernel/device-drivers/block/kernel_space/test_block.c deleted file mode 100644 index 3048e09..0000000 --- a/testcases/kernel/device-drivers/block/kernel_space/test_block.c +++ /dev/null @@ -1,310 +0,0 @@ - -/* - * Module under test: linux/block/genhd.c - * - * Only those functions are tested here which are declared in <linux/fs.h> - * - * Usage: - * 1. make - * 2. su - * 3. insmod ./test_block.ko - * 4. Check the test results in "dmesg" - * 5. rmmod test_block - * - * Changes: - * 16 Jan 2009 0.2 Added "tc" parameter to run test cases separately - * 11 Jan 2009 0.1 First release - */ - -#include <linux/module.h> -#include <linux/fs.h> - -static unsigned int __initdata tc; -module_param_named(tc, tc, int, 0); -MODULE_PARM_DESC(tc, - "Test Case to run. Default is 0 which means that run all tests."); - -MODULE_AUTHOR("Márton Németh <nm...@fr...>"); -MODULE_DESCRIPTION("Test block drivers"); -MODULE_LICENSE("GPL"); - -#define BLK_DEV_NAME "test_block" -#define MAX_MAJOR 255 - -/* - * Analysis of "int register_blkdev(unsigned int major, const char *name)" - * - * Equivalence classes: - * - * Parameter | Values | Valid? | Covered in - * -----------+--------------------------+---------+------------- - * major | [0] | valid | tc01, tc02 - * |--------------------------+---------+------------- - * | [1..255] | valid | tc05 - * |--------------------------+---------+------------- - * | [256..UINT_MAX] | invalid | tc03, tc04 - * -----------+--------------------------+---------+------------- - * name | [valid pointer to a zero | | - * | terminated string] | valid | tc01, tc02 - * |--------------------------+---------+------------- - * | [valid pointer to a zero | | - * | length zero terminated | invalid | tc06 - * | string] | | - * |--------------------------+---------+------------- - * | [NULL] | invalid | tc07 - * -----------+--------------------------+---------+------------- - * - */ - -static void tc01(void) -{ - int major1; - int major2; - - printk(KERN_INFO - "Test Case 1: register_blkdev() with auto allocating major numbers (major=0)\n"); - - major1 = register_blkdev(0, BLK_DEV_NAME); - printk(KERN_DEBUG "major1 = %i\n", major1); - - major2 = register_blkdev(0, BLK_DEV_NAME); - printk(KERN_DEBUG "major2 = %i\n", major2); - - if (0 < major1) { - unregister_blkdev(major1, BLK_DEV_NAME); - } else { - printk(KERN_DEBUG - "first call to register_blkdev() failed with error %i\n", - major1); - } - - if (0 < major2) { - unregister_blkdev(major2, BLK_DEV_NAME); - } else { - printk(KERN_DEBUG - "second call to register_blkdev() failed with error %i\n", - major2); - } - - printk(KERN_INFO "Test Case 1: UNRESLOVED\n"); -} - -static void tc02(void) -{ - int major[MAX_MAJOR + 1]; - int i; - - /* Try to allocate block devices until all major number are used. After this - * register_blkdev() should return -EBUSY - */ - - printk(KERN_INFO - "Test Case 2: stress test of register_blkdev() with auto allocating major numbers (major=0)\n"); - - memset(major, 0, sizeof(major)); - - for (i = 0; i < sizeof(major) / sizeof(*major); i++) { - major[i] = register_blkdev(0, BLK_DEV_NAME); - printk(KERN_DEBUG "major[%i] = %i\n", i, major[i]); - if (major[i] <= 0 && major[i] != -EBUSY) { - printk(KERN_INFO - "unexpected return value from register_blkdev(): %i\n", - major[i]); - } - if (major[i] < 0) { - printk(KERN_DEBUG - "register_blkdev() failed with error %i\n", - major[i]); - } - } - - for (i = 0; i < sizeof(major) / sizeof(*major); i++) { - if (0 < major[i]) { - unregister_blkdev(major[i], BLK_DEV_NAME); - major[i] = 0; - } - } - - printk(KERN_INFO "Test Case 2: UNRESLOVED\n"); -} - -static void tc03(void) -{ - int major; - - printk(KERN_INFO "Test Case 3: register_blkdev() with major=256\n"); - - major = register_blkdev(256, BLK_DEV_NAME); - printk(KERN_DEBUG "major = %i\n", major); - - if (0 < major) { - unregister_blkdev(major, BLK_DEV_NAME); - } else { - printk(KERN_DEBUG "register_blkdev() failed with error %i\n", - major); - } - - printk(KERN_INFO "Test Case 3: UNRESLOVED\n"); -} - -static void tc04(void) -{ - int major; - - printk(KERN_INFO "Test Case 4: register_blkdev() with major=%u\n", - UINT_MAX); - - major = register_blkdev(UINT_MAX, BLK_DEV_NAME); - printk(KERN_DEBUG "major = %i\n", major); - - if (0 < major) { - unregister_blkdev(major, BLK_DEV_NAME); - } else { - printk(KERN_DEBUG "register_blkdev() failed with error %i\n", - major); - } - - printk(KERN_INFO "Test Case 4: UNRESLOVED\n"); -} - -static void tc05(void) -{ - int major; - int major2; - int major3; - - printk(KERN_INFO "Test Case 5: register_blkdev() with major != 0\n"); - - /* autosearch for a free major number */ - major = register_blkdev(0, BLK_DEV_NAME); - printk(KERN_DEBUG "major = %i\n", major); - - if (0 < major) { - unregister_blkdev(major, BLK_DEV_NAME); - - major2 = register_blkdev(major, BLK_DEV_NAME); - major3 = register_blkdev(major, BLK_DEV_NAME); - - if (0 < major2) { - unregister_blkdev(major2, BLK_DEV_NAME); - } else { - printk(KERN_DEBUG - "first call to register_blkdev() with major=%i failed with error %i\n", - major, major2); - } - - if (0 < major3) { - unregister_blkdev(major3, BLK_DEV_NAME); - } else { - printk(KERN_DEBUG - "second call to register_blkdev() with major=%i failed with error %i\n", - major, major3); - } - - } else { - printk(KERN_DEBUG "register_blkdev() failed with error %i\n", - major); - } - - printk(KERN_INFO "Test Case 5: UNRESLOVED\n"); -} - -static void tc06(void) -{ - int major; - - printk(KERN_INFO "Test Case 6: register_blkdev() with name=\"\"\n"); - - major = register_blkdev(0, ""); - printk(KERN_DEBUG "major = %i\n", major); - - if (0 < major) { - unregister_blkdev(major, ""); - } else { - printk(KERN_DEBUG "register_blkdev() failed with error %i\n", - major); - } - - printk(KERN_INFO "Test Case 6: UNRESLOVED\n"); -} - -static void tc07(void) -{ - int major; - - printk(KERN_INFO "Test Case 7: register_blkdev() with name=NULL\n"); - - major = register_blkdev(0, NULL); - printk(KERN_DEBUG "major = %i\n", major); - - if (0 < major) { - unregister_blkdev(major, NULL); - } else { - printk(KERN_DEBUG "register_blkdev() failed with error %i\n", - major); - } - - printk(KERN_INFO "Test Case 7: UNRESLOVED\n"); -} - -static void tc10(void) -{ - int major; - - printk(KERN_INFO "Test Case 10: unregister_blkdev() with major=0\n"); - - major = register_blkdev(0, BLK_DEV_NAME); - printk(KERN_DEBUG "major = %i\n", major); - - if (0 < major) { - printk(KERN_DEBUG "calling unregister_blkdev() with major=0\n"); - unregister_blkdev(0, BLK_DEV_NAME); - printk(KERN_DEBUG "calling unregister_blkdev() with major=%i\n", - major); - unregister_blkdev(major, BLK_DEV_NAME); - } else { - printk(KERN_DEBUG "register_blkdev() failed with error %i\n", - major); - } - - printk(KERN_INFO "Test Case 10: UNRESLOVED\n"); -} - -static int test_init_module(void) -{ - printk(KERN_INFO "Starting test_block module\n"); - - if (tc == 0 || tc == 1) - tc01(); - - if (tc == 0 || tc == 2) - tc02(); - - if (tc == 0 || tc == 3) - tc03(); - - if (tc == 0 || tc == 4) - tc04(); - - if (tc == 0 || tc == 5) - tc05(); - - if (tc == 0 || tc == 6) - tc06(); - - if (tc == 0 || tc == 7) - tc07(); - - if (tc == 0 || tc == 10) - tc10(); - - return 0; -} - -static void test_exit_module(void) -{ - printk(KERN_DEBUG "Unloading test_block module\n"); -} - -module_init(test_init_module); -module_exit(test_exit_module); diff --git a/testcases/kernel/firmware/Makefile b/testcases/kernel/firmware/Makefile index dd2c62d..57b598d 100644 --- a/testcases/kernel/firmware/Makefile +++ b/testcases/kernel/firmware/Makefile @@ -17,28 +17,4 @@ top_srcdir ?= ../../.. include $(top_srcdir)/include/mk/env_pre.mk - -SUBDIRS = -REQ_VERSION_MAJOR = 3 -REQ_VERSION_PATCH = 7 - -ifeq ($(MAKECMDGOALS),clean) -SKIP = 0 -endif - -ifeq ($(WITH_MODULES),yes) -SKIP ?= $(shell test $(LINUX_VERSION_MAJOR) -gt $(REQ_VERSION_MAJOR); echo $$?) -ifeq ($(SKIP),1) -SKIP = $(shell test $(LINUX_VERSION_MAJOR) -eq $(REQ_VERSION_MAJOR); echo $$?) -ifeq ($(SKIP),0) -SKIP = $(shell test $(LINUX_VERSION_PATCH) -ge $(REQ_VERSION_PATCH); echo $$?) -endif -endif -endif - -ifeq ($(SKIP),0) -SUBDIRS += fw_load_kernel -endif -SUBDIRS += fw_load_user - include $(top_srcdir)/include/mk/generic_trunk_target.mk diff --git a/testcases/kernel/firmware/fw_load_kernel/Makefile b/testcases/kernel/firmware/fw_load_kernel/Makefile index 076d4ed..7399699 100644 --- a/testcases/kernel/firmware/fw_load_kernel/Makefile +++ b/testcases/kernel/firmware/fw_load_kernel/Makefile @@ -25,18 +25,11 @@ else top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/env_pre.mk +REQ_VERSION_MAJOR := 3 +REQ_VERSION_PATCH := 7 MAKE_TARGETS := ltp_fw_load.ko -# Ignoring the exit status of commands is done to be forward compatible with -# kernel internal API changes. The user-space test will return TCONF, if it -# doesn't find the module (i.e. it wasn't built either due to kernel-devel -# missing or module build failure). -ltp_fw_load.ko: ltp_fw_load.c - -$(MAKE) -C $(LINUX_DIR) M=$(abs_srcdir) - -mv ltp_fw_load.ko ltp_fw_load.ko~ - -$(MAKE) -C $(LINUX_DIR) M=$(abs_srcdir) clean - -mv ltp_fw_load.ko~ ltp_fw_load.ko - +include $(top_srcdir)/include/mk/module.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk endif hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-01 15:51:15
|
The branch, master, has been updated via 971bcd7e51e4e6f94a58374f9b3cd22e53e7e53e (commit) via 8ddc6cd37204819e67dbb2b7164475ebb21b02dd (commit) via b5077cf12f122b97ee69f0f1438071ef1ddd66e3 (commit) via aeafd8315e2d0d31207b54e6b246f1dae4836e18 (commit) via 87156a05a2ffd50f5e467d6f986daae9da7b9cf7 (commit) via 08f8781892b8a28efbba8b4104beacb623ce39dd (commit) via 27f2cc5998cd63a26a3c3d679bd1dec40cf741e7 (commit) from 8b458d6e9125dee8be4dd08b9ab7db79b3873c5f (commit) - Log ----------------------------------------------------------------- commit 971bcd7e51e4e6f94a58374f9b3cd22e53e7e53e Author: Stanislav Kholmanskikh <sta...@or...> Date: Tue Oct 1 17:44:54 2013 +0400 cpuset/cpuset_load_balance_test: fixes Fixed lack of '#include "config.h"', perform some cleanup and set nr_cpus, nr_mems based on environment. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit 8ddc6cd37204819e67dbb2b7164475ebb21b02dd Author: Stanislav Kholmanskikh <sta...@or...> Date: Tue Oct 1 17:44:53 2013 +0400 cpuset_memory_spread_test: number of nodes and sync For unification number of nodes is set based on environment. OS caches were not reliably dropped after execution of 'dd' on DATAFILE. And since 'dd' was executed in root cpuset the caches were spread among all available memory nodes. Because on consecutive reading of DATAFILE in cpuset_mem_hog didn't increase memory consumption. This situation caused random failures of the testcase. In accordance to Documentation/sysctl/vm.txt to reliably drop caches we should invoke 'sync' before 'echo N > /proc/sys/vm/drop_caches'. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit b5077cf12f122b97ee69f0f1438071ef1ddd66e3 Author: Stanislav Kholmanskikh <sta...@or...> Date: Tue Oct 1 17:44:52 2013 +0400 cpuset/cpuset_memory_test: fixes cpuset_memory_test.c: * lack of "config.h" * incorrect use of HAVE_LINUX_MEMPOLICY macro * modification to make use of sigwaitinfo * some cleanup cpuset_memory_testset.sh: * number of cpu and memory nodes are set based on environment * we send second SIGUSR1 signal to make the child free its resources * setting nr_hugepages to a value of 2 is not sufficient. Because there is no guarantee that these hugepages will be allocated on the specified node * cleanup and several typos are fixed Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit aeafd8315e2d0d31207b54e6b246f1dae4836e18 Author: Stanislav Kholmanskikh <sta...@or...> Date: Tue Oct 1 17:44:51 2013 +0400 cpuset/cpuset_lib: cpuinfo.c compiled incorrectly Because of lack of '#include "config.h"' cpuinfo.c file was compiled incorrectly (i.e. final lib libcpu_set.a didn't contain the functions/variables from cpuinfo.c) Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit 87156a05a2ffd50f5e467d6f986daae9da7b9cf7 Author: Stanislav Kholmanskikh <sta...@or...> Date: Tue Oct 1 17:44:50 2013 +0400 cpuset/cpuset_syscall_test: fixes cpuset_syscall_test.c: I suppose that now there is no need in many '#if' and explicit definition of functions get_mempolicy, set_mempolicy, mbind. Including numa.h and numaif.h (as we do in the other testcases) should be sufficient. cpuset_syscall_testset.sh: Since linux kernel 3.8.0 (commit 5606e3877ad8baea42f3a71ebde0a03622bbb551 "mm: numa: Migrate on reference policy") default task memory policy and its output in /proc/<pid>/numa_maps changed. For example in 3.7.10 for stack vma /proc/<pid>/numa_maps show: 7fff81e01000 default stack anon=3 dirty=3 N3=3 but in 3.8.0: 7fff08950000 prefer:3 stack anon=5 dirty=5 N2=4 N3=1 So modified a check in test 10 and removed unnessesary checks for "default" memory policy from tests 14, 15, 16. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit 08f8781892b8a28efbba8b4104beacb623ce39dd Author: Stanislav Kholmanskikh <sta...@or...> Date: Tue Oct 1 17:44:49 2013 +0400 cpuset/cpuset_base_ops_test: fix expected error At least since kernel 3.0.0 writing '0-' to $CPUSET/N/{cpus, mems} files doesn't raise an error. Reading content of these files after writing gives '0'. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit 27f2cc5998cd63a26a3c3d679bd1dec40cf741e7 Author: Stanislav Kholmanskikh <sta...@or...> Date: Tue Oct 1 17:44:48 2013 +0400 controllers/cpuset: removed bash sweetnesses Signed-off-by: Stanislav Kholmanskikh <sta...@or...> ----------------------------------------------------------------------- Summary of changes: .../cpuset_base_ops_testset.sh | 28 +++- .../cpuset_exclusive_test/cpuset_exclusive_test.sh | 6 +- .../kernel/controllers/cpuset/cpuset_funcs.sh | 2 +- .../cpuset_hierarchy_test/cpuset_hierarchy_test.sh | 6 +- .../cpuset_hotplug_test/cpuset_hotplug_test.sh | 6 +- .../cpuset_inherit_test/cpuset_inherit_testset.sh | 6 +- .../kernel/controllers/cpuset/cpuset_lib/cpuinfo.c | 1 + .../cpuset_load_balance_test/cpuset_cpu_hog.c | 16 +- .../cpuset_load_balance_test.sh | 10 +- .../cpuset_sched_domains_check.c | 1 + .../cpuset_sched_domains_test.sh | 11 +- .../cpuset_memory_pressure_testset.sh | 6 +- .../cpuset_memory_spread_testset.sh | 74 ++++++---- .../cpuset/cpuset_memory_test/cpuset_memory_test.c | 159 ++++++++++---------- .../cpuset_memory_test/cpuset_memory_testset.sh | 24 ++-- .../cpuset/cpuset_syscall_test/Makefile | 1 + .../cpuset_syscall_test/cpuset_syscall_test.c | 61 ++------ .../cpuset_syscall_test/cpuset_syscall_testset.sh | 22 ++-- .../kernel/controllers/cpuset/run_cpuset_test.sh | 6 +- 19 files changed, 226 insertions(+), 220 deletions(-) diff --git a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh index a40c46b..126eec5 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/cpuset_base_ops_testset.sh @@ -24,12 +24,12 @@ cd $LTPROOT/testcases/bin -. ./cpuset_funcs.sh - export TCID="cpuset01" export TST_TOTAL=97 export TST_COUNT=1 +. ./cpuset_funcs.sh + nr_cpus=$NR_CPUS nr_mems=$N_NODES @@ -97,7 +97,7 @@ base_op_test() exit_status=1 fi fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) } test_cpus() @@ -117,7 +117,6 @@ test_cpus() 0-$((nr_cpus-1)) 0-$((nr_cpus-1)) -1 WRITE_ERROR 0-$nr_cpus WRITE_ERROR - 0- WRITE_ERROR 0--$((nr_cpus-1)) WRITE_ERROR 0,1-$((nr_cpus-2)),$((nr_cpus-1)) 0-$((nr_cpus-1)) 0,1-$((nr_cpus-2)), 0-$((nr_cpus-2)) @@ -125,6 +124,13 @@ test_cpus() AAA WRITE_ERROR EOF # while read cpus result + + tst_kvercmp 3 0 0 + if [ $? -eq 0 ]; then + base_op_test "$CPUSET/1/cpus" "0-" "WRITE_ERROR" + else + base_op_test "$CPUSET/1/cpus" "0-" "0" + fi } test_mems() @@ -144,7 +150,6 @@ test_mems() 0-$((nr_mems-1)) 0-$((nr_mems-1)) -1 WRITE_ERROR 0-$nr_mems WRITE_ERROR - 0- WRITE_ERROR 0--$((nr_mems-1)) WRITE_ERROR 0,1-$((nr_mems-2)),$((nr_mems-1)) 0-$((nr_mems-1)) 0,1-$((nr_mems-2)), 0-$((nr_mems-2)) @@ -152,6 +157,13 @@ test_mems() AAA WRITE_ERROR EOF # while read mems result + + tst_kvercmp 3 0 0 + if [ $? -eq 0 ]; then + base_op_test "$CPUSET/1/mems" "0-" "WRITE_ERROR" + else + base_op_test "$CPUSET/1/mems" "0-" "0" + fi } test_flags() @@ -190,7 +202,7 @@ attach_task_test() if [ $? -ne 0 ]; then exit_status=1 cleanup - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) return fi @@ -199,7 +211,7 @@ attach_task_test() if [ $? -ne 0 ]; then exit_status=1 cleanup - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) return fi @@ -227,7 +239,7 @@ attach_task_test() if [ $? -ne 0 ]; then exit_status=1 fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) } diff --git a/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh b/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh index 363317c..0ad31e7 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/cpuset_exclusive_test.sh @@ -24,12 +24,12 @@ cd $LTPROOT/testcases/bin -. ./cpuset_funcs.sh - export TCID="cpuset03" export TST_TOTAL=18 export TST_COUNT=1 +. ./cpuset_funcs.sh + exit_status=0 # Case 1-9 test cpus @@ -238,7 +238,7 @@ do exit_status=1 fi fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) done exit $exit_status diff --git a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh index b996461..a83845c 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh @@ -31,7 +31,7 @@ else N_NODES="`cat /sys/devices/system/node/has_normal_memory`" fi N_NODES=${N_NODES#*-*} -: $((N_NODES++)) +N_NODES=$(($N_NODES + 1)) CPUSET="/dev/cpuset" CPUSET_TMP="/tmp/cpuset_tmp" diff --git a/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh b/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh index 1b633c1..5804aa4 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/cpuset_hierarchy_test.sh @@ -24,12 +24,12 @@ cd $LTPROOT/testcases/bin -. ./cpuset_funcs.sh - export TCID="cpuset04" export TST_TOTAL=32 export TST_COUNT=1 +. ./cpuset_funcs.sh + nr_cpus=$NR_CPUS nr_mems=$N_NODES @@ -463,7 +463,7 @@ do exit_status=1 fi fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) done exit $exit_status diff --git a/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh b/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh index 205152c..2bfe0f5 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/cpuset_hotplug_test.sh @@ -24,12 +24,12 @@ cd $LTPROOT/testcases/bin -. ./cpuset_funcs.sh - export TCID="cpuset08" export TST_TOTAL=13 export TST_COUNT=1 +. ./cpuset_funcs.sh + exit_status=0 nr_cpus=$NR_CPUS @@ -218,7 +218,7 @@ base_test() cpu_hotplug_cleanup fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) } # Test Case 1-2 diff --git a/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh index 27d9a61..780b7eb 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_inherit_test/cpuset_inherit_testset.sh @@ -24,12 +24,12 @@ cd $LTPROOT/testcases/bin -. ./cpuset_funcs.sh - export TCID="cpuset02" export TST_TOTAL=27 export TST_COUNT=1 +. ./cpuset_funcs.sh + nr_cpus=$NR_CPUS nr_mems=$N_NODES @@ -97,7 +97,7 @@ inherit_test() exit_status=1 fi fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) } test_cpus() diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c b/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c index 65c5072..3e7961f 100644 --- a/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c +++ b/testcases/kernel/controllers/cpuset/cpuset_lib/cpuinfo.c @@ -1,3 +1,4 @@ +#include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c index 4b4e965..5dd2ced 100644 --- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c +++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c @@ -20,6 +20,7 @@ /* */ /******************************************************************************/ +#include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -33,24 +34,23 @@ #include <sys/stat.h> #include <fcntl.h> +char *TCID = "cpuset_cpu_hog"; +int TST_TOTAL = 1; + +#if HAVE_LINUX_MEMPOLICY_H + #include "../cpuset_lib/common.h" #include "../cpuset_lib/bitmask.h" #include "../cpuset_lib/cpuset.h" -#if HAVE_LINUX_MEMPOLICY_H - #define MAX_NPROCS 1000 #define USAGE ("Usage: %s [-p nprocs] [-h]\n" \ "\t-p nprocs\n" \ "\t\tThe num of the procs. [Default = 2 * nr_cpus]\n" \ "\t-h\tHelp.\n") -char *TCID = "cpuset_cpu_hog"; -int TST_TOTAL = 1; - -unsigned long count; -int nprocs; -volatile int end; +static int nprocs; +static volatile int end; /* * report executing result to the parent by fifo diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh index 854be72..55f533a 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_load_balance_test.sh @@ -24,17 +24,17 @@ cd $LTPROOT/testcases/bin -. ./cpuset_funcs.sh - export TCID="cpuset07" export TST_TOTAL=13 export TST_COUNT=1 +. ./cpuset_funcs.sh + exit_status=0 # must >= 3 for: 1-$((nr_mems-2)) -nr_cpus=4 -nr_mems=3 +nr_cpus=$NR_CPUS +nr_mems=$N_NODES cpus_all="$(seq -s, 0 $((nr_cpus-1)))" mems_all="$(seq -s, 0 $((nr_mems-1)))" @@ -307,7 +307,7 @@ base_test() cpu_hotplug_cleanup fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) } test_general_load_balance1() diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_check.c b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_check.c index 9fe4f01..15259e7 100644 --- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_check.c +++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_check.c @@ -20,6 +20,7 @@ /* */ /******************************************************************************/ +#include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh index bfead80..3ca70df 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh @@ -24,17 +24,17 @@ cd $LTPROOT/testcases/bin -. ./cpuset_funcs.sh - export TCID="cpuset06" export TST_TOTAL=19 export TST_COUNT=1 +. ./cpuset_funcs.sh + exit_status=0 # must >= 3 for: 1-$((nr_mems-2)) -nr_cpus=4 -nr_mems=3 +nr_cpus=$NR_CPUS +nr_mems=$N_NODES cpus_all="$(seq -s, 0 $((nr_cpus-1)))" mems_all="$(seq -s, 0 $((nr_mems-1)))" @@ -222,7 +222,7 @@ base_test() cpu_hotplug_cleanup fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) } # Casee 1-6 @@ -236,7 +236,6 @@ test_root_load_balance() while read isbalance level hotplug do base_test $isbalance $hotplug - : $((file_case_num++)) done <<- EOF 0 none 1 none diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh index 185a028..f342e6c 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/cpuset_memory_pressure_testset.sh @@ -24,12 +24,12 @@ cd $LTPROOT/testcases/bin -. ./cpuset_funcs.sh - export TCID="cpuset10" export TST_TOTAL=6 export TST_COUNT=1 +. ./cpuset_funcs.sh + exit_status=0 # usable physical memory @@ -254,7 +254,7 @@ do fi fi fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) done exit $exit_status diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh index 0a954c0..ffce419 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh @@ -24,16 +24,16 @@ cd $LTPROOT/testcases/bin -. ./cpuset_funcs.sh - export TCID="cpuset11" export TST_TOTAL=6 export TST_COUNT=1 +. ./cpuset_funcs.sh + exit_status=0 # must >= 3 for: 1-$((nr_mems-2)) -nr_cpus=4 -nr_mems=3 +nr_cpus=$NR_CPUS +nr_mems=$N_NODES # In general, the cache hog will use more than 10000 kb slab space on the nodes # on which it is running. The other nodes' slab space has littler change.(less @@ -48,15 +48,45 @@ nodedir="/sys/devices/system/node" FIFO="./myfifo" -declare -a memsinfo +# memsinfo is an array implementation of the form of a multi-line string +# _0: value0 +# _1: value1 +# _2: value2 +# +memsinfo="" -init_mems_info_array() +# set value to memsinfo ($1 - index, $2 - value) +set_memsinfo_val() +{ + local nl=' +' + # clearing existent value (if present) + memsinfo=`echo "$memsinfo" | sed -r "/^\_$1\:\s/d"` + + if [ -z "$memsinfo" ]; then + memsinfo="_$1: $2" + else + memsinfo="$memsinfo${nl}_$1: $2" + fi +} + +# get value from memsinfo ($1 - index) +get_memsinfo_val() +{ + local value= + value=`echo "$memsinfo" | grep -e "^\_$1\:\s"` + value=`echo "$value" | sed -r "s/^.*\:\s(.*)$/\1/"` + echo "$value" +} + + +init_memsinfo_array() { local i= for i in `seq 0 $((nr_mems-1))` do - memsinfo[$i]=0 + set_memsinfo_val $i 0 done } @@ -67,8 +97,8 @@ get_meminfo() local nodepath="$nodedir/node$nodeid" local nodememinfo="$nodepath/meminfo" local item="$2" - local infoarray=(`cat $nodememinfo | grep $item`) - memsinfo[$nodeid]=${infoarray[3]} + local info=`cat $nodememinfo | grep $item | awk '{print $4}'` + set_memsinfo_val $nodeid $info } # freemem_check @@ -88,7 +118,7 @@ freemem_check() for i in `seq 0 $((nr_mems-1))` do # I think we need 100MB free memory to run test - if [ ${memsinfo[$i]} -lt 100000 ]; then + if [ $(get_memsinfo_val $i) -lt 100000 ]; then return 1 fi done @@ -109,9 +139,9 @@ get_memsinfo() account_meminfo() { local nodeId="$1" - local tmp="${memsinfo[$nodeId]}" + local tmp="$(get_memsinfo_val $nodeId)" get_meminfo $@ "FilePages" - memsinfo[$nodeId]=$((${memsinfo[$nodeId]}-$tmp)) + set_memsinfo_val $nodeId $(($(get_memsinfo_val $nodeId)-$tmp)) } # account_memsinfo @@ -136,7 +166,7 @@ result_check() for i in $nodelist do - if [ ${memsinfo[$i]} -le $upperlimit ]; then + if [ $(get_memsinfo_val $i) -le $upperlimit ]; then return 1 fi done @@ -153,7 +183,7 @@ result_check() for i in $othernodelist do - if [ ${memsinfo[$i]} -gt $lowerlimit ]; then + if [ $(get_memsinfo_val $i) -gt $lowerlimit ]; then return 1 fi done @@ -193,6 +223,7 @@ general_memory_spread_test() fi # we'd better drop the caches before we test page cache. + sync /bin/echo 3 > /proc/sys/vm/drop_caches 2> $CPUSET_TMP/stderr if [ $? -ne 0 ]; then cpuset_log_error $CPUSET_TMP/stderr @@ -200,9 +231,6 @@ general_memory_spread_test() return 1 fi - # wait for droping the cache - sleep 10 - get_memsinfo /bin/kill -s SIGUSR1 $test_pid read exit_num < $FIFO @@ -214,7 +242,7 @@ general_memory_spread_test() account_memsinfo result_check $expect_nodes if [ $? -ne 0 ]; then - tst_resm TFAIL "hog the memory on the unexpected node(FilePages_For_Nodes(KB): ${memsinfo[*]}, Expect Nodes: $expect_nodes)." + tst_resm TFAIL "hog the memory on the unexpected node(FilePages_For_Nodes(KB): ${memsinfo}, Expect Nodes: $expect_nodes)." return 1 fi } @@ -246,7 +274,7 @@ base_test() tst_resm TPASS "Cpuset memory spread page test succeeded." fi fi - ((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) } # test general spread page cache in a cpuset @@ -301,7 +329,7 @@ test_spread_page2() fi } -init_mems_info_array +init_memsinfo_array freemem_check if [ $? -ne 0 ]; then tst_brkm TFAIL ignored "Some node doesn't has enough free memory(100MB) to do test(MemFree_For_Nodes(KB): ${memsinfo[*]})." @@ -314,12 +342,6 @@ if [ $? -ne 0 ]; then exit 1 fi -# drop page caches -/bin/echo 1 > /proc/sys/vm/drop_caches - -# wait for droping caches -sleep 10 - mkfifo $FIFO if [ $? -ne 0 ]; then rm -f DATAFILE diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c index ddf5935..e4206cf 100644 --- a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c +++ b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c @@ -20,6 +20,7 @@ /* */ /******************************************************************************/ +#include "config.h" #include <unistd.h> #include <stdlib.h> #include <stdio.h> @@ -36,27 +37,26 @@ #include <syscall.h> #include <pthread.h> -#include "../cpuset_lib/cpuset.h" - char *TCID = "cpuset_memory_test"; int TST_TOTAL = 1; -#if HAVE_LINUX_MEMPOLICY_TEST +#if HAVE_LINUX_MEMPOLICY_H + +#include "../cpuset_lib/cpuset.h" -int fd; -int flag_exit; +static int fd; -int opt_mmap_anon; -int opt_mmap_file; -int opt_mmap_lock1; -int opt_mmap_lock2; -int opt_shm; -int opt_hugepage; -int opt_check; /* check node when munmap memory (only for mmap_anon()) */ -int opt_thread; +static int opt_mmap_anon; +static int opt_mmap_file; +static int opt_mmap_lock1; +static int opt_mmap_lock2; +static int opt_shm; +static int opt_hugepage; +static int opt_check; /* check node when munmap memory (only for mmap_anon()) */ +static int opt_thread; -int key_id; /* used with opt_shm */ -unsigned long memsize; +static int key_id; /* used with opt_shm */ +static unsigned long memsize; #define FILE_HUGEPAGE "/hugetlb/hugepagefile" @@ -136,7 +136,7 @@ void process_options(int argc, char *argv[]) } if (!memsize) - memsize = getpagesize(); + memsize = sysconf(_SC_PAGESIZE); } /* @@ -145,7 +145,7 @@ void process_options(int argc, char *argv[]) void touch_memory_and_echo_node(char *p, int size) { int i; - int pagesize = getpagesize(); + int pagesize = sysconf(_SC_PAGESIZE); for (i = 0; i < size; i += pagesize) p[i] = 0xef; @@ -281,90 +281,54 @@ void shm(int flag_allocated) } } -/* - * sigint_handler: handle SIGINT by set the exit flag. - */ -void sigint_handler(int __attribute__ ((unused)) signo) -{ - flag_exit = 1; -} - -/* - * sigusr_handler: handler SIGUSR - * - * When we receive SIGUSR, we allocate some memory according - * to the user input when the process started. - * - * When we recive SIGUSR again, we will free all the allocated - * memory. - */ -void sigusr_handler(int __attribute__ ((unused)) signo) -{ - static int flag_allocated = 0; - - if (opt_mmap_anon) - mmap_anon(flag_allocated); - - if (opt_mmap_file) - mmap_file(flag_allocated); - - if (opt_mmap_lock1) - mmap_lock1(flag_allocated); - - if (opt_mmap_lock2) - mmap_lock2(flag_allocated); - - if (opt_shm) - shm(flag_allocated); - - flag_allocated = !flag_allocated; -} - -void sigusr2(int __attribute__ ((unused)) signo) -{ - static int flag_allocated = 0; - mmap_anon(flag_allocated); - flag_allocated = !flag_allocated; -} - void *thread2_routine(void __attribute__ ((unused)) * arg) { sigset_t set; - struct sigaction sigusr2_action; + sigset_t waitset; + int flag_allocated; sigemptyset(&set); sigaddset(&set, SIGUSR1); sigaddset(&set, SIGINT); pthread_sigmask(SIG_BLOCK, &set, NULL); - memset(&sigusr2_action, 0, sizeof(sigusr2_action)); - sigusr2_action.sa_handler = &sigusr2; - sigaction(SIGUSR2, &sigusr2_action, NULL); + sigemptyset(&waitset); + sigaddset(&waitset, SIGUSR2); + pthread_sigmask(SIG_BLOCK, &waitset, NULL); + + flag_allocated = 0; + + for (;;) { + if (sigwaitinfo(&waitset, NULL) < 0) + err(1, "sigwaitinfo() in thread2 failed"); - while (!flag_exit) - sleep(1); + mmap_anon(flag_allocated); + flag_allocated = !flag_allocated; + } return NULL; } +/* + * When we receive SIGUSR1, we allocate some memory according + * to the user intput when the process started. + * When we receive SIGUSR1 again, we will free all the allocated + * memory. + * Similiar for --thread option but SIGUSR2 signal is used + * to control thread2 behaviour. + */ int main(int argc, char *argv[]) { - struct sigaction sigint_action; - struct sigaction sigusr_action; + sigset_t waitset; + int signo; + int flag_allocated; + pthread_t thread2; fd = open("/dev/zero", O_RDWR); if (fd < 0) err(1, "open /dev/zero failed"); - memset(&sigint_action, 0, sizeof(sigint_action)); - sigint_action.sa_handler = &sigint_handler; - sigaction(SIGINT, &sigint_action, NULL); - - memset(&sigusr_action, 0, sizeof(sigusr_action)); - sigusr_action.sa_handler = &sigusr_handler; - sigaction(SIGUSR1, &sigusr_action, NULL); - process_options(argc, argv); if (opt_thread) { @@ -377,8 +341,41 @@ int main(int argc, char *argv[]) pthread_sigmask(SIG_BLOCK, &set, NULL); } - while (!flag_exit) - sleep(1); + + sigemptyset(&waitset); + sigaddset(&waitset, SIGINT); + sigaddset(&waitset, SIGUSR1); + + pthread_sigmask(SIG_BLOCK, &waitset, NULL); + + flag_allocated = 0; + + for (;;) { + signo = sigwaitinfo(&waitset, NULL); + if (signo < 0) + err(1, "sigwaitinfo() failed"); + + if (signo == SIGUSR1) { + if (opt_mmap_anon) + mmap_anon(flag_allocated); + + if (opt_mmap_file) + mmap_file(flag_allocated); + + if (opt_mmap_lock1) + mmap_lock1(flag_allocated); + + if (opt_mmap_lock2) + mmap_lock2(flag_allocated); + + if (opt_shm) + shm(flag_allocated); + + flag_allocated = !flag_allocated; + } else { + break; + } + } if (opt_thread) { void *retv; diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh index b117932..2a9f7e3 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_testset.sh @@ -22,19 +22,19 @@ # # ################################################################################ -. ./cpuset_funcs.sh - cd $LTPROOT/testcases/bin export TCID="cpuset09" export TST_TOTAL=18 export TST_COUNT=1 +. ./cpuset_funcs.sh + exit_status=0 # must >= 3 for: 1-$((nr_mems-2)) -nr_cpus=4 -nr_mems=3 +nr_cpus=$NR_CPUS +nr_mems=$N_NODES cpus_all="$(seq -s, 0 $((nr_cpus-1)))" mems_all="$(seq -s, 0 $((nr_mems-1)))" @@ -55,6 +55,8 @@ simple_getresult() echo $1 > "$2/tasks" /bin/kill -s SIGUSR1 $1 sleep 1 + /bin/kill -s SIGUSR1 $1 + sleep 1 /bin/kill -s SIGINT $1 wait $1 read node < "$MEMORY_RESULT" @@ -150,7 +152,7 @@ test5() # 1 - support hugetlbfs check_hugetlbfs() { - local fssupport="grep -w hugetlbfs /proc/filesystems 2>/dev/null | cut -f2" + local fssupport=$(grep -w hugetlbfs /proc/filesystems 2>/dev/null | cut -f2) if [ "$fssupport" = "hugetlbfs" ]; then return 1 @@ -178,7 +180,7 @@ test6() mount -t hugetlbfs none /hugetlb save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages) - echo 2 > /proc/sys/vm/nr_hugepages + echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages ./cpuset_memory_test --mmap-file --hugepage -s $HUGEPAGESIZE >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" @@ -187,7 +189,7 @@ test6() rmdir /hugetlb echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages - if [ $! -ne 0 ]; then + if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)." return 1 fi @@ -217,7 +219,7 @@ test7() mount -t hugetlbfs none /hugetlb save_nr_hugepages=$(cat /proc/sys/vm/nr_hugepages) - echo 2 > /proc/sys/vm/nr_hugepages + echo $((2*$nr_mems)) > /proc/sys/vm/nr_hugepages ./cpuset_memory_test --shm --hugepage -s $HUGEPAGESIZE --key=7 >"$MEMORY_RESULT" & simple_getresult $! "$CPUSET/0" @@ -226,7 +228,7 @@ test7() rmdir /hugetlb echo $save_nr_hugepages > /proc/sys/vm/nr_hugepages - if [ $! -ne 0 ]; then + if [ $(cat /proc/sys/vm/nr_hugepages) -ne $save_nr_hugepages ]; then tst_resm TFAIL "can't restore nr_hugepages(nr_hugepages = $save_nr_hugepages)." return 1 fi @@ -821,11 +823,11 @@ do if [ $? -ne 0 ]; then exit_status=1 else - tst_resm TPASS "Cpuset memory alloaction test succeeded." + tst_resm TPASS "Cpuset memory allocation test succeeded." fi fi fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) done exit $exit_status diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile index 6565631..54393e7 100644 --- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile +++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile @@ -26,6 +26,7 @@ include $(top_srcdir)/include/mk/testcases.mk include $(abs_srcdir)/../Makefile.inc LDLIBS += $(NUMA_LIBS) +CPPFLAGS += $(NUMA_CPPFLAGS) include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c index 5c30763..dd35cd0 100644 --- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c +++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c @@ -22,6 +22,7 @@ #define _GNU_SOURCE +#include "config.h" #include <sched.h> #include <unistd.h> #include <stdlib.h> @@ -38,49 +39,29 @@ #include <sys/shm.h> #include <syscall.h> #include <inttypes.h> -#include "config.h" -#include "linux_syscall_numbers.h" +#if HAVE_NUMA_H +#include <numa.h> +#endif +#if HAVE_NUMAIF_H +#include <numaif.h> +#endif + #include "test.h" #include "usctest.h" char *TCID = "cpuset_syscall_test"; +int TST_TOTAL = 1; -#if HAVE_LINUX_MEMPOLICY_H -#include <linux/mempolicy.h> +#if HAVE_NUMA_H && HAVE_LINUX_MEMPOLICY_H && HAVE_NUMAIF_H \ + && HAVE_MPOL_CONSTANTS #include "../cpuset_lib/cpuset.h" #include "../cpuset_lib/bitmask.h" -int TST_TOTAL = 1; - -unsigned long mask; -int test = -1; -int flag_exit; -int ret; - -#if HAVE_DECL_MPOL_F_MEMS_ALLOWED -static int get_mempolicy(int *policy, unsigned long *nmask, - unsigned long maxnode, void *addr, int flags) -{ - return ltp_syscall(__NR_get_mempolicy, policy, nmask, maxnode, addr, - flags); -} -#endif - -#if HAVE_DECL_MPOL_BIND -static int mbind(void *start, unsigned long len, int policy, - unsigned long *nodemask, unsigned long maxnode, unsigned flags) -{ - return ltp_syscall(__NR_mbind, start, len, policy, nodemask, maxnode, - flags); -} - -static int set_mempolicy(int policy, unsigned long *nodemask, - unsigned long maxnode) -{ - return ltp_syscall(__NR_set_mempolicy, policy, nodemask, maxnode); -} -#endif +static unsigned long mask; +static int test = -1; +static int flag_exit; +static int ret; #define OPT_setaffinity (SCHAR_MAX + 1) #define OPT_getaffinity (SCHAR_MAX + 2) @@ -178,20 +159,12 @@ void test_mbind(void) return; } printf("%p\n", addr); -#if HAVE_DECL_MPOL_BIND ret = mbind(addr, len, MPOL_BIND, &mask, 8 * sizeof(mask), 0); -#else - ret = 1; -#endif } void test_set_mempolicy(void) { -#if HAVE_DECL_MPOL_BIND ret = set_mempolicy(MPOL_BIND, &mask, 8 * sizeof(mask)); -#else - ret = -1; -#endif } void test_get_mempolicy(void) @@ -213,12 +186,8 @@ void test_get_mempolicy(void) ret = 1; return; } -#if HAVE_DECL_MPOL_F_MEMS_ALLOWED ret = get_mempolicy(NULL, bitmask_mask(nmask), bitmask_nbits(nmask), 0, MPOL_F_MEMS_ALLOWED); -#else - ret = -1; -#endif bitmask_displaylist(str, 256, nmask); puts(str); diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh index 02a41a3..af92373 100755 --- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh +++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh @@ -24,12 +24,12 @@ cd $LTPROOT/testcases/bin -. ./cpuset_funcs.sh - export TCID="cpuset05" export TST_TOTAL=16 export TST_COUNT=1 +. ./cpuset_funcs.sh + exit_status=0 TEST_CPUSET="$CPUSET/0" @@ -230,15 +230,20 @@ test10() allowed_list=$(cat $TEST_PROCNUMA | grep "$memory_addr" | \ awk '{print $2}') allowed_list="$(echo $allowed_list | sed -e s/bind://)" - test "$allowed_list" = "default" + + task_policy=$(cat $TEST_PROCNUMA | grep -e "\s\+stack\s\+anon" | \ + awk '{print $2}') + + test "$allowed_list" = "$task_policy" if [ $? -ne 0 ]; then - tst_resm TFAIL "Result(/proc/<pid>/status) = \"$allowed_list\", expect = \"default\")" + tst_resm TFAIL "Result(/proc/<pid>/status) = \"$allowed_list\",\ + expect = \"$task_policy\")" return 1 fi return 0 } -# this function is used by case 11-16 +# this function is used by case 11-13 # check_result <expect> check_result() { @@ -279,8 +284,7 @@ test13() test14() { do_syscall_test 0 0 --set_mempolicy=6 1 || return 1 - check_result "default" - return $? + return 0 } test15() @@ -297,7 +301,6 @@ test15() tst_resm TFAIL "Result(/proc/<pid>/status) = \"$allowed_list\", expect = \"0\")" return 1 fi - check_result "default" || return 1 return 0 } @@ -315,7 +318,6 @@ test16() tst_resm TFAIL "Result(/proc/<pid>/status) = \"$allowed_list\", expect = \"0-1\")" return 1 fi - check_result "default" || return 1 return 0 } @@ -338,7 +340,7 @@ do fi fi fi - : $((TST_COUNT++)) + TST_COUNT=$(($TST_COUNT + 1)) done exit $exit_status diff --git a/testcases/kernel/controllers/cpuset/run_cpuset_test.sh b/testcases/kernel/controllers/cpuset/run_cpuset_test.sh index ee269f9..abdc885 100755 --- a/testcases/kernel/controllers/cpuset/run_cpuset_test.sh +++ b/testcases/kernel/controllers/cpuset/run_cpuset_test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # usage ./run_cpuset_test.sh test_num ################################################################################ @@ -41,12 +41,12 @@ # # ################################################################################ -source cpuset_funcs.sh; - export TCID="cpuset_test"; export TST_TOTAL=1; export TST_COUNT=1; +. cpuset_funcs.sh; + TEST_NUM=$1; SCRIPT_PID=$$; RC=0; hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-01 14:51:09
|
The branch, master, has been updated via 8b458d6e9125dee8be4dd08b9ab7db79b3873c5f (commit) via 2b515b00642c573ca5e4b40d0991cf4125a34802 (commit) via f2f4645b389f4ddb7e6e714fa621f782eeed0106 (commit) from f3b989fe1765ee5992a377c53b1f94990a033dfe (commit) - Log ----------------------------------------------------------------- commit 8b458d6e9125dee8be4dd08b9ab7db79b3873c5f Author: Cyril Hrubis <ch...@su...> Date: Tue Oct 1 16:23:34 2013 +0200 ltpapicmd.c: Fix the printf() format warnings. * Fixes printf format warnings * Remove useless allocations and strcpy() Signed-off-by: Cyril Hrubis <ch...@su...> commit 2b515b00642c573ca5e4b40d0991cf4125a34802 Author: Stanislav Kholmanskikh <sta...@or...> Date: Tue Oct 1 15:35:59 2013 +0400 ltpapicmd.c: split main into separate functions Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit f2f4645b389f4ddb7e6e714fa621f782eeed0106 Author: Stanislav Kholmanskikh <sta...@or...> Date: Tue Oct 1 15:35:58 2013 +0400 tools: added tst_kvercmp2 binary Signed-off-by: Stanislav Kholmanskikh <sta...@or...> ----------------------------------------------------------------------- Summary of changes: tools/apicmds/.gitignore | 1 + tools/apicmds/Makefile | 4 +- tools/apicmds/ltpapicmd.c | 282 ++++++++++++++++++++++++++++++-------------- 3 files changed, 195 insertions(+), 92 deletions(-) diff --git a/tools/apicmds/.gitignore b/tools/apicmds/.gitignore index e895739..a6d73d3 100644 --- a/tools/apicmds/.gitignore +++ b/tools/apicmds/.gitignore @@ -3,6 +3,7 @@ tst_brkm tst_exit tst_flush tst_kvercmp +tst_kvercmp2 tst_ncpus tst_ncpus_max tst_res diff --git a/tools/apicmds/Makefile b/tools/apicmds/Makefile index faa49b5..3cadc3f 100644 --- a/tools/apicmds/Makefile +++ b/tools/apicmds/Makefile @@ -26,8 +26,8 @@ include $(top_srcdir)/include/mk/testcases.mk CPPFLAGS += -D_GNU_SOURCE -MAKE_TARGETS := $(addprefix tst_,brk brkm exit flush kvercmp res resm \ - ncpus ncpus_max) +MAKE_TARGETS := $(addprefix tst_,brk brkm exit flush kvercmp kvercmp2 \ + res resm ncpus ncpus_max) include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/tools/apicmds/ltpapicmd.c b/tools/apicmds/ltpapicmd.c index e2b0061..8fae62a 100644 --- a/tools/apicmds/ltpapicmd.c +++ b/tools/apicmds/ltpapicmd.c @@ -45,8 +45,11 @@ * 0 - on success * -1 - on failure * - * Description: Unlike the above commands tst_kvercmp has an unusual exit status - * tst_kvercmp - Compare running kernel to specified version + * Description: Unlike the above commands tst_kvercmp, tst_kvercmp2 have an unusual + * exit status + * tst_kvercmp - Compare running kernel to specified version + * tst_kvercmp2 - Compare running kernel to specified vanilla version + * or distribution specific version * Exit: * 2 - running newer kernel * 1 - running same age kernel @@ -76,6 +79,11 @@ char *TCID; /* Name of the testcase */ int TST_TOTAL; /* Total number of testcases */ +static char cmd_name[1024]; /* name by which this program is invoked tst_brk etc */ +static char *tst_total; /* total number of tests in the file. */ +static char *tst_cntstr; /* sets the value of tst_count with this value */ + + /* * Function: ident_ttype - Return test result type. * @@ -108,6 +116,179 @@ int ident_ttype(char *tstype) return -1; } +void apicmd_brk(int argc, char *argv[]) +{ + int trestype; + char *file_name; + + if (argc < 5) { + fprintf(stderr, "Usage: %s TTYPE FNAME FUNC STRING\n" + "\tTTYPE - Test Result Type; one of TFAIL, TBROK, TCONF, " + "and TRETR.\n" + "\tFNAME - Print contents of this file after the message\n" + "\tFUNC - Cleanup function (ignored), but MUST be provided\n" + "\tSTRING - Message explaining the test result\n", + cmd_name); + exit(1); + } + trestype = ident_ttype((argv++)[0]); + file_name = (argv++)[0]; + argv++; + tst_brk(trestype, file_name, NULL, "%s", *argv); +} + +void apicmd_res(int argc, char *argv[]) +{ + int trestype; + char *file_name; + + if (argc < 4) { + fprintf(stderr, "Usage: %s TTYPE FNAME STRING\n" + "\tTTYPE - Test Result Type; one of TFAIL, TBROK, TCONF, " + "and TRETR.\n" + "\tFNAME - Print contents of this file after the message\n" + "\tSTRING - Message explaining the test result\n", + cmd_name); + exit(1); + } + trestype = ident_ttype((argv++)[0]); + file_name = (argv++)[0]; + tst_res(trestype, file_name, "%s", *argv); +} + +void apicmd_brkm(int argc, char *argv[]) +{ + int trestype; + + if (argc < 4) { + fprintf(stderr, "Usage: %s TTYPE FUNC STRING\n" + "\tTTYPE - Test Result Type; one of TFAIL, TBROK, TCONF, " + "and TRETR.\n" + "\tFUNC - Cleanup function (ignored), but MUST be provided\n" + "\tSTRING - Message explaining the test result\n", + cmd_name); + exit(1); + } + trestype = ident_ttype((argv++)[0]); + argv++; + tst_brkm(trestype, NULL, "%s", *argv); +} + +void apicmd_resm(int argc, char *argv[]) +{ + int trestype; + + if (argc < 3) { + fprintf(stderr, "Usage: %s TTYPE STRING\n" + "\tTTYPE - Test Result Type; one of TFAIL, TBROK, TCONF, " + "and TRETR.\n" + "\tSTRING - Message explaining the test result\n", + cmd_name); + exit(1); + } + trestype = ident_ttype((argv++)[0]); + tst_resm(trestype, "%s", *argv); +} + +void apicmd_kvercmp(int argc, char *argv[]) +{ + int exit_value; + + if (argc < 4) { + fprintf(stderr, "Usage: %s NUM NUM NUM\n" + "Compares to the running kernel version.\n\n" + "\tNUM - A positive integer.\n" + "\tThe first NUM is the kernel VERSION\n" + "\tThe second NUM is the kernel PATCHLEVEL\n" + "\tThe third NUM is the kernel SUBLEVEL\n\n" + "\tExit status is 0 if the running kernel is older than the\n" + "\t\tkernel specified by NUM NUM NUM.\n" + "\tExit status is 1 for kernels of the same age.\n" + "\tExit status is 2 if the running kernel is newer.\n", + cmd_name); + exit(1); + } + exit_value = tst_kvercmp(atoi(argv[0]), atoi(argv[1]), + atoi(argv[2])); + if (exit_value < 0) + exit_value = 0; + else if (exit_value == 0) + exit_value = 1; + else if (exit_value > 0) + exit_value = 2; + exit(exit_value); +} + +void apicmd_kvercmp2(int argc, char *argv[]) +{ + int exit_value; + + struct tst_kern_exv vers[100]; + unsigned int count; + + char *saveptr1 = NULL; + char *saveptr2 = NULL; + char *token1; + + if (TCID == NULL) + TCID = "outoftest"; + if (tst_cntstr == NULL) + tst_count = 0; + + if (argc < 5) { + fprintf(stderr, "Usage: %s NUM NUM NUM KVERS\n" + "Compares to the running kernel version\n" + "based on vanilla kernel version NUM NUM NUM\n" + "or distribution specific kernel version KVERS\n\n" + "\tNUM - A positive integer.\n" + "\tThe first NUM is the kernel VERSION\n" + "\tThe second NUM is the kernel PATCHLEVEL\n" + "\tThe third NUM is the kernel SUBLEVEL\n\n" + "\tKVERS is a string of the form " + "\"DISTR1:VERS1 DISTR2:VERS2\",\n" + "\twhere DISTR1 is a distribution name\n" + "\tand VERS1 is the corresponding kernel version.\n" + "\tExample: \"RHEL6:2.6.39-400.208\"\n\n" + "\tIf running kernel matches a distribution in KVERS then\n" + "\tcomparison is performed based on version in KVERS,\n" + "\totherwise - based on NUM NUM NUM.\n\n" + "\tExit status is 0 if the running kernel is older.\n" + "\tExit status is 1 for kernels of the same age.\n" + "\tExit status is 2 if the running kernel is newer.\n", + cmd_name); + exit(3); + } + + count = 0; + token1 = strtok_r(argv[3], " ", &saveptr1); + while ((token1 != NULL) && (count < 99)) { + vers[count].dist_name = strtok_r(token1, ":", &saveptr2); + vers[count].extra_ver = strtok_r(NULL, ":", &saveptr2); + + if (vers[count].extra_ver == NULL) { + fprintf(stderr, "Incorrect KVERS format\n"); + exit(3); + } + + count++; + + token1 = strtok_r(NULL, " ", &saveptr1); + } + vers[count].dist_name = NULL; + vers[count].extra_ver = NULL; + + exit_value = tst_kvercmp2(atoi(argv[0]), atoi(argv[1]), + atoi(argv[2]), vers); + + if (exit_value < 0) + exit_value = 0; + else if (exit_value == 0) + exit_value = 1; + else if (exit_value > 0) + exit_value = 2; + exit(exit_value); +} + /* * Function: main - entry point of this program * @@ -135,23 +316,14 @@ int ident_ttype(char *tstype) */ int main(int argc, char *argv[]) { - int trestype; /* test result type TFAIL, TPASS, TINFO etc */ - char *arg_fmt; /* message string printed along with test type */ - char *cmd_name; /* name by which this program is invoked tst_brk etc */ - char *tst_total; /* total number of tests in the file. */ - char *tst_cntstr; /* sets the value of tst_count with this value */ - char *file_name; /* contents of this file are printed; see tst_res() */ - - arg_fmt = SAFE_MALLOC(NULL, 1024); - cmd_name = SAFE_MALLOC(NULL, 1024); - strcpy(cmd_name, SAFE_BASENAME(NULL, (argv++)[0])); TCID = getenv("TCID"); tst_total = getenv("TST_TOTAL"); tst_cntstr = getenv("TST_COUNT"); if (TCID == NULL || tst_total == NULL || tst_cntstr == NULL) { - if (strcmp(cmd_name, "tst_kvercmp") != 0) { + if ((strcmp(cmd_name, "tst_kvercmp") != 0) + && (strcmp(cmd_name, "tst_kvercmp2") != 0)) { fprintf(stderr, "\nSet variables TCID, TST_TOTAL, and TST_COUNT before each test:\n" "export TCID=<test name>\n" @@ -180,91 +352,21 @@ int main(int argc, char *argv[]) } if (strcmp(cmd_name, "tst_brk") == 0) { - if (argc < 5) { - fprintf(stderr, "Usage: %s TTYPE FNAME FUNC STRING\n" - "\tTTYPE - Test Result Type; one of TFAIL, TBROK, TCONF, " - "and TRETR.\n" - "\tFNAME - Print contents of this file after the message\n" - "\tFUNC - Cleanup function (ignored), but MUST be provided\n" - "\tSTRING - Message explaining the test result\n", - cmd_name); - exit(1); - } - trestype = ident_ttype((argv++)[0]); - file_name = (argv++)[0]; - argv++; - strcpy(arg_fmt, *argv); - tst_brk(trestype, file_name, NULL, arg_fmt); + apicmd_brk(argc, argv); } else if (strcmp(cmd_name, "tst_res") == 0) { - if (argc < 4) { - fprintf(stderr, "Usage: %s TTYPE FNAME STRING\n" - "\tTTYPE - Test Result Type; one of TFAIL, TBROK, TCONF, " - "and TRETR.\n" - "\tFNAME - Print contents of this file after the message\n" - "\tSTRING - Message explaining the test result\n", - cmd_name); - exit(1); - } - trestype = ident_ttype((argv++)[0]); - file_name = (argv++)[0]; - strcpy(arg_fmt, *argv); - tst_res(trestype, file_name, arg_fmt); + apicmd_res(argc, argv); } else if (strcmp(cmd_name, "tst_brkm") == 0) { - if (argc < 4) { - fprintf(stderr, "Usage: %s TTYPE FUNC STRING\n" - "\tTTYPE - Test Result Type; one of TFAIL, TBROK, TCONF, " - "and TRETR.\n" - "\tFUNC - Cleanup function (ignored), but MUST be provided\n" - "\tSTRING - Message explaining the test result\n", - cmd_name); - exit(1); - } - trestype = ident_ttype((argv++)[0]); - argv++; - strcpy(arg_fmt, *argv); - tst_brkm(trestype, NULL, arg_fmt); + apicmd_brkm(argc, argv); } else if (strcmp(cmd_name, "tst_resm") == 0) { - if (argc < 3) { - fprintf(stderr, "Usage: %s TTYPE STRING\n" - "\tTTYPE - Test Result Type; one of TFAIL, TBROK, TCONF, " - "and TRETR.\n" - "\tSTRING - Message explaining the test result\n", - cmd_name); - exit(1); - } - trestype = ident_ttype((argv++)[0]); - strcpy(arg_fmt, *argv); - tst_resm(trestype, arg_fmt); + apicmd_resm(argc, argv); } else if (strcmp(cmd_name, "tst_exit") == 0) { tst_exit(); } else if (strcmp(cmd_name, "tst_flush") == 0) { tst_flush(); } else if (strcmp(cmd_name, "tst_kvercmp") == 0) { - int exit_value; - - if (argc < 4) { - fprintf(stderr, "Usage: %s NUM NUM NUM\n" - "Compares to the running kernel version.\n\n" - "\tNUM - A positive integer.\n" - "\tThe first NUM is the kernel VERSION\n" - "\tThe second NUM is the kernel PATCHLEVEL\n" - "\tThe third NUM is the kernel SUBLEVEL\n\n" - "\tExit status is 0 if the running kernel is older than the\n" - "\t\tkernel specified by NUM NUM NUM.\n" - "\tExit status is 1 for kernels of the same age.\n" - "\tExit status is 2 if the running kernel is newer.\n", - cmd_name); - exit(1); - } - exit_value = tst_kvercmp(atoi(argv[0]), atoi(argv[1]), - atoi(argv[2])); - if (exit_value < 0) - exit_value = 0; - else if (exit_value == 0) - exit_value = 1; - else if (exit_value > 0) - exit_value = 2; - exit(exit_value); + apicmd_kvercmp(argc, argv); + } else if (strcmp(cmd_name, "tst_kvercmp2") == 0) { + apicmd_kvercmp2(argc, argv); } else if (strcmp(cmd_name, "tst_ncpus") == 0) { printf("%li\n", tst_ncpus()); } else if (strcmp(cmd_name, "tst_ncpus_max") == 0) { hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-10-01 13:51:20
|
The branch, master, has been updated via f3b989fe1765ee5992a377c53b1f94990a033dfe (commit) via e05a5d3d174931707f3dfe9193f26b9c34497255 (commit) from 7f5bfb8ff65dfb8f910e25de65bf68291488924c (commit) - Log ----------------------------------------------------------------- commit f3b989fe1765ee5992a377c53b1f94990a033dfe Author: Cyril Hrubis <ch...@su...> Date: Tue Oct 1 15:37:02 2013 +0200 doc: Add documentation for module.mk The example Makefile is taken from commit message from the previous commit by Alexey Kodanev. Signed-off-by: Cyril Hrubis <ch...@su...> commit e05a5d3d174931707f3dfe9193f26b9c34497255 Author: Alexey Kodanev <ale...@or...> Date: Tue Oct 1 15:32:25 2013 +0400 mk/module.mk: add Makefile to build kernel modules Makefile example: ifneq ($(KERNELRELEASE),) obj-m := module01.o else top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk REQ_VERSION_MAJOR := 2 REQ_VERSION_PATCH := 6 MAKE_TARGETS := test01 test02 module01.ko include $(top_srcdir)/include/mk/module.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk endif Signed-off-by: Alexey Kodanev <ale...@or...> Reviewed-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: doc/build-system-guide.txt | 42 ++++++++++++++++++++ .../Makefile => include/mk/module.mk | 36 +++++++++------- 2 files changed, 62 insertions(+), 16 deletions(-) copy testcases/kernel/firmware/fw_load_kernel/Makefile => include/mk/module.mk (57%) diff --git a/doc/build-system-guide.txt b/doc/build-system-guide.txt index ea9966e..25ea158 100644 --- a/doc/build-system-guide.txt +++ b/doc/build-system-guide.txt @@ -73,6 +73,48 @@ include $(top_srcdir)/include/mk/env_pre.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk ------------------------------------------------------------------------------- +Kernel Modules +-------------- + +Some of the tests need to build kernel modules, happily LTP has +infrastructure for this. + +------------------------------------------------------------------------------- +ifneq ($(KERNELRELEASE),) + +obj-m := module01.o + +else + +top_srcdir ?= ../../../.. +include $(top_srcdir)/include/mk/testcases.mk + +REQ_VERSION_MAJOR := 2 +REQ_VERSION_PATCH := 6 +MAKE_TARGETS := test01 test02 module01.ko + +include $(top_srcdir)/include/mk/module.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk + +endif +------------------------------------------------------------------------------- + +This is example Makefile that allows you build kernel modules inside of LTP. +The prerequisities for the build are detected by the 'configure' script. + +The 'REQ_VERSION_MAJOR' and 'REQ_VERSION_PATCH' describe minimal kernel +version for which the build system tries to build the module. + +The buildsystem is also forward compatible with changes in Linux kernel +internal API so that if modul fails to build the failure is ignored both on +build and installation. If the userspace counterpart of the test fails to load +the module because the file does not exists, the test is skipped. + +Note the 'ifneq($(KERNELRELEASE),)', the reason it's there is that the +Makefile is executed twice, once by LTP build system and once by kernel +kbuild, see 'Documentation/kbuild/modules.txt' in the Linux kernel tree for +details on external module build. + Make Rules and Make Variables ----------------------------- diff --git a/testcases/kernel/firmware/fw_load_kernel/Makefile b/include/mk/module.mk similarity index 57% copy from testcases/kernel/firmware/fw_load_kernel/Makefile copy to include/mk/module.mk index 076d4ed..b903e8f 100644 --- a/testcases/kernel/firmware/fw_load_kernel/Makefile +++ b/include/mk/module.mk @@ -13,30 +13,34 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# Author: Alexey Kodanev <ale...@or...> +# +# Include it to build kernel modules. +# REQ_VERSION_MAJOR and REQ_VERSION_PATCH must be defined beforehand. +# -ifneq ($(KERNELRELEASE),) +$(if $(REQ_VERSION_MAJOR),,$(error You must define REQ_VERSION_MAJOR)) +$(if $(REQ_VERSION_PATCH),,$(error You must define REQ_VERSION_MINOR)) -ifdef CONFIG_FW_LOADER -obj-m := ltp_fw_load.o +ifneq ($(filter install clean,$(MAKECMDGOALS)),) +SKIP := 2 endif -else - -top_srcdir ?= ../../../.. -include $(top_srcdir)/include/mk/env_pre.mk +SKIP ?= $(shell [ "$(WITH_MODULES)" = yes ] && \ + [ $(LINUX_VERSION_MAJOR) -gt $(REQ_VERSION_MAJOR) ] || \ + [ $(LINUX_VERSION_MAJOR) -eq $(REQ_VERSION_MAJOR) -a \ + $(LINUX_VERSION_PATCH) -ge $(REQ_VERSION_PATCH) ]; echo $$?) -MAKE_TARGETS := ltp_fw_load.ko +ifneq ($(SKIP),0) +MAKE_TARGETS := $(filter-out %.ko, $(MAKE_TARGETS)) +MAKE_TARGETS += $(if $(filter 2,$(SKIP)),$(wildcard *.ko),) +endif # Ignoring the exit status of commands is done to be forward compatible with # kernel internal API changes. The user-space test will return TCONF, if it # doesn't find the module (i.e. it wasn't built either due to kernel-devel # missing or module build failure). -ltp_fw_load.ko: ltp_fw_load.c +%.ko: %.c -$(MAKE) -C $(LINUX_DIR) M=$(abs_srcdir) - -mv ltp_fw_load.ko ltp_fw_load.ko~ - -$(MAKE) -C $(LINUX_DIR) M=$(abs_srcdir) clean - -mv ltp_fw_load.ko~ ltp_fw_load.ko - -include $(top_srcdir)/include/mk/generic_leaf_target.mk - -endif + rm -rf *.mod.c *.o modules.order .tmp* .*.ko .*.cmd Module.symvers hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-09-26 11:51:14
|
The branch, master, has been updated via 7f5bfb8ff65dfb8f910e25de65bf68291488924c (commit) from 5cdeb8d4b889e7b25ba8a9754243474bef5798d3 (commit) - Log ----------------------------------------------------------------- commit 7f5bfb8ff65dfb8f910e25de65bf68291488924c Author: MaShimiao <mas...@cn...> Date: Thu Sep 26 17:42:02 2013 +0800 setuid/setuid04.c: Fix a double cleanup() error The cleanup() may be called twice by both the parent and child process in this testcase leading to a failure. This patch makes sure cleanup() is called only once by parent process. Signed-off-by: Zeng Linggang <zen...@cn...> Signed-off-by: Ma Shimiao <mas...@cn...> Reviewed-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/setuid/setuid04.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/testcases/kernel/syscalls/setuid/setuid04.c b/testcases/kernel/syscalls/setuid/setuid04.c index d8e991e..365859b 100644 --- a/testcases/kernel/syscalls/setuid/setuid04.c +++ b/testcases/kernel/syscalls/setuid/setuid04.c @@ -88,7 +88,7 @@ static void do_master_child(void) int pid; int status; - if (SETUID(cleanup, ltpuser->pw_uid) == -1) { + if (SETUID(NULL, ltpuser->pw_uid) == -1) { tst_brkm(TBROK, NULL, "setuid failed to set the effective uid to %d", ltpuser->pw_uid); hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-09-17 14:51:10
|
The branch, master, has been updated via 5cdeb8d4b889e7b25ba8a9754243474bef5798d3 (commit) from 15f7303b0e7c6fba634208745b9b7d49c24567c8 (commit) - Log ----------------------------------------------------------------- commit 5cdeb8d4b889e7b25ba8a9754243474bef5798d3 Author: Cyril Hrubis <ch...@su...> Date: Tue Sep 17 15:55:53 2013 +0200 syscalls: syslog: Fix daemon restart on SUSE. Some distributions (at least SUSE) names the service 'syslog' even if the syslog binary is named syslog-ng or rsyslog. This patch adds codepath that tries restart "syslog" service if previous attempt has failed. Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/syslog/syslog-lib.sh | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/testcases/kernel/syscalls/syslog/syslog-lib.sh b/testcases/kernel/syscalls/syslog/syslog-lib.sh index 0885805..9c5d7f1 100755 --- a/testcases/kernel/syscalls/syslog/syslog-lib.sh +++ b/testcases/kernel/syscalls/syslog/syslog-lib.sh @@ -124,7 +124,16 @@ restart_syslog_daemon() # then it needs to be fixed. sleep 2 else - $cleanup_command + # + # Some distributions name the service syslog even if + # the package is syslog-ng or rsyslog, so try it once + # more with just syslog. + # + restart_daemon "syslog" + + if [ $? -ne 0 ]; then + $cleanup_command + fi fi fi } hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-09-17 11:51:14
|
The branch, master, has been updated via 15f7303b0e7c6fba634208745b9b7d49c24567c8 (commit) from 0e7a99b5316fdefc8fb8df77e7d0e2abff7511ac (commit) - Log ----------------------------------------------------------------- commit 15f7303b0e7c6fba634208745b9b7d49c24567c8 Author: Stanislav Kholmanskikh <sta...@or...> Date: Tue Sep 17 14:55:01 2013 +0400 syscalls/getgroups: use TCID_DEFINE Signed-off-by: Stanislav Kholmanskikh <sta...@or...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/getgroups/getgroups01.c | 2 +- testcases/kernel/syscalls/getgroups/getgroups03.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/syscalls/getgroups/getgroups01.c b/testcases/kernel/syscalls/getgroups/getgroups01.c index f319ebf..bbb6409 100644 --- a/testcases/kernel/syscalls/getgroups/getgroups01.c +++ b/testcases/kernel/syscalls/getgroups/getgroups01.c @@ -60,7 +60,7 @@ static void setup(void); static void cleanup(void); -char *TCID = "getgroups01"; +TCID_DEFINE(getgroups01); int TST_TOTAL = 4; static GID_T gidset[NGROUPS]; diff --git a/testcases/kernel/syscalls/getgroups/getgroups03.c b/testcases/kernel/syscalls/getgroups/getgroups03.c index 5e46792..e1f879d 100644 --- a/testcases/kernel/syscalls/getgroups/getgroups03.c +++ b/testcases/kernel/syscalls/getgroups/getgroups03.c @@ -45,7 +45,7 @@ #define TESTUSER "root" -char *TCID = "getgroups03"; +TCID_DEFINE(getgroups03); int TST_TOTAL = 1; static int ngroups; hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-09-16 15:51:19
|
The branch, master, has been updated via 0e7a99b5316fdefc8fb8df77e7d0e2abff7511ac (commit) from 3a7395c6a04622a848e472426ab28ecc13a81b6b (commit) - Log ----------------------------------------------------------------- commit 0e7a99b5316fdefc8fb8df77e7d0e2abff7511ac Author: Stanislav Kholmanskikh <sta...@or...> Date: Fri Sep 13 13:59:10 2013 +0400 setfsgid, setfsuid: clean up and 16-bit version fixes Signed-off-by: Stanislav Kholmanskikh <sta...@or...> Signed-off-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/setfsgid/setfsgid01.c | 100 ++++--------- testcases/kernel/syscalls/setfsgid/setfsgid02.c | 105 +++++--------- testcases/kernel/syscalls/setfsgid/setfsgid03.c | 128 ++++++---------- testcases/kernel/syscalls/setfsuid/setfsuid01.c | 100 ++++--------- testcases/kernel/syscalls/setfsuid/setfsuid02.c | 106 ++++--------- testcases/kernel/syscalls/setfsuid/setfsuid03.c | 128 ++++++----------- testcases/kernel/syscalls/setfsuid/setfsuid04.c | 181 ++++++++++------------- testcases/kernel/syscalls/utils/compat_16.h | 13 ++ 8 files changed, 311 insertions(+), 550 deletions(-) diff --git a/testcases/kernel/syscalls/setfsgid/setfsgid01.c b/testcases/kernel/syscalls/setfsgid/setfsgid01.c index fc2af5b..f87bace 100644 --- a/testcases/kernel/syscalls/setfsgid/setfsgid01.c +++ b/testcases/kernel/syscalls/setfsgid/setfsgid01.c @@ -1,62 +1,41 @@ /* + * Copyright (c) International Business Machines Corp., 2001 + * Ported by Wayne Boyer * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * NAME - * setfsgid01.c - * - * DESCRIPTION - * Testcase to check the basic functionality of setfsgid(2) system - * call. - * - * ALGORITHM - * Call setfsgid() and test the return value. - * If this value is not same as that of the user's gid, then fail. - * - * USAGE: <for command-line> - * setfsgid01 [-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 + * Testcase to check the basic functionality of setfsgid(2) system call. */ + #include <stdio.h> #include <unistd.h> #include <sys/fsuid.h> #include <sys/types.h> #include <errno.h> + #include "test.h" #include "usctest.h" +#include "compat_16.h" -char *TCID = "setfsgid01"; +TCID_DEFINE(setfsgid01); int TST_TOTAL = 1; -void setup(void); -void cleanup(void); +static void setup(void); +static void cleanup(void); int main(int ac, char **av) { @@ -65,29 +44,27 @@ int main(int ac, char **av) gid_t gid; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } 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; gid = getegid(); + GID16_CHECK(gid, setfsgid, cleanup); - TEST(setfsgid(gid)); + TEST(SETFSGID(cleanup, gid)); if (TEST_RETURN == -1) { - tst_resm(TFAIL, "call failed unexpectedly - errno %d", - TEST_ERRNO); + tst_resm(TFAIL | TTERRNO, + "setfsgid() failed unexpectedly"); continue; } if (!STD_FUNCTIONAL_TEST) { - tst_resm(TPASS, "call succeeded"); + tst_resm(TPASS, "setfsgid() succeeded"); continue; } @@ -95,37 +72,24 @@ int main(int ac, char **av) tst_resm(TFAIL, "setfsgid() returned %ld, expected %d", TEST_RETURN, gid); } else { - tst_resm(TPASS, "setfsgid() returned expected value : " - "%d", gid); + tst_resm(TPASS, + "setfsgid() returned expected value : %ld", + TEST_RETURN); } } + cleanup(); tst_exit(); - tst_exit(); - } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; - } diff --git a/testcases/kernel/syscalls/setfsgid/setfsgid02.c b/testcases/kernel/syscalls/setfsgid/setfsgid02.c index c4c6880..250d677 100644 --- a/testcases/kernel/syscalls/setfsgid/setfsgid02.c +++ b/testcases/kernel/syscalls/setfsgid/setfsgid02.c @@ -1,66 +1,44 @@ /* + * Copyright (C) International Business Machines Corp., 2001 + * Ported by Wayne Boyer + * Adapted by Dustin Kirkland (k1r...@us...) * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * NAME - * setfsgid02.c - * - * DESCRIPTION - * Testcase to check the basic functionality of setfsgid(2) system - * call failures. - * - * ALGORITHM - * Call setfsgid() and test the return value when invalid gid used. - * - * USAGE: <for command-line> - * setfsgid01 [-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 - * 04/2003 Adapted by Dustin Kirkland (k1r...@us...) - * - * RESTRICTIONS - * None + * Testcase to check the basic functionality of setfsgid(2) system + * call failures. */ + #include <stdio.h> #include <unistd.h> #include <grp.h> #include <pwd.h> #include <sys/types.h> #include <errno.h> -#ifdef __GLIBC__ -#include <sys/fsuid.h> -#endif + #include "test.h" #include "usctest.h" +#include "compat_16.h" -char *TCID = "setfsgid02"; +TCID_DEFINE(setfsgid02); int TST_TOTAL = 1; -void setup(void); -void cleanup(void); +static void setup(void); +static void cleanup(void); int main(int ac, char **av) { @@ -69,32 +47,30 @@ int main(int ac, char **av) gid_t gid; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } 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; gid = 1; - while (getgrgid(gid)) { + while (getgrgid(gid)) gid++; - } - TEST(setfsgid(gid)); + GID16_CHECK(gid, setfsgid, cleanup); + + TEST(SETFSGID(cleanup, gid)); if (TEST_RETURN == -1) { - tst_resm(TFAIL, "call failed unexpectedly - errno %d", - TEST_ERRNO); + tst_resm(TFAIL | TTERRNO, + "setfsgid() failed unexpectedly"); continue; } if (!STD_FUNCTIONAL_TEST) { - tst_resm(TPASS, "call succeeded"); + tst_resm(TPASS, "setfsgid() succeeded"); continue; } @@ -106,32 +82,19 @@ int main(int ac, char **av) "%ld", TEST_RETURN); } } - cleanup(); - return EXIT_SUCCESS; + cleanup(); + tst_exit(); } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; - } diff --git a/testcases/kernel/syscalls/setfsgid/setfsgid03.c b/testcases/kernel/syscalls/setfsgid/setfsgid03.c index 8345160..ae351b8 100644 --- a/testcases/kernel/syscalls/setfsgid/setfsgid03.c +++ b/testcases/kernel/syscalls/setfsgid/setfsgid03.c @@ -1,68 +1,47 @@ /* + * Copyright (C) International Business Machines Corp., 2001 + * Ported by Wayne Boyer + * Adapted by Dustin Kirkland (k1r...@us...) * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * NAME - * setfsgid03.c - * - * DESCRIPTION - * Testcase to check the basic functionality of setfsgid(2) system - * call fails when called by a non-root user. - * - * ALGORITHM - * Call setfsgid() and test the return value. - * - * USAGE: <for command-line> - * setfsgid01 [-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 - * 04/2003 Adapted by Dustin Kirkland (k1r...@us...) - * - * RESTRICTIONS - * None + * Testcase to check the basic functionality of setfsgid(2) system + * call fails when called by a non-root user. */ + #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <errno.h> #include <pwd.h> #include <grp.h> -#ifdef __GLIBC__ -#include <sys/fsuid.h> -#endif + #include "test.h" #include "usctest.h" +#include "compat_16.h" -char *TCID = "setfsgid03"; +TCID_DEFINE(setfsgid03); int TST_TOTAL = 1; -char nobody_uid[] = "nobody"; -struct passwd *ltpuser; -void setup(void); -void cleanup(void); +static char nobody_uid[] = "nobody"; +static struct passwd *ltpuser; + +static void setup(void); +static void cleanup(void); int main(int ac, char **av) { @@ -71,32 +50,30 @@ int main(int ac, char **av) gid_t gid; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } 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; gid = 1; - while (!getgrgid(gid)) { + while (!getgrgid(gid)) gid++; - } - TEST(setfsgid(gid)); + GID16_CHECK(gid, setfsgid, cleanup); + + TEST(SETFSGID(cleanup, gid)); if (TEST_RETURN == -1) { - tst_resm(TFAIL, "call failed unexpectedly - errno %d", - TEST_ERRNO); + tst_resm(TFAIL | TTERRNO, + "setfsgid() failed unexpectedly"); continue; } if (!STD_FUNCTIONAL_TEST) { - tst_resm(TPASS, "call succeeded"); + tst_resm(TPASS, "setfsgid() succeeded"); continue; } @@ -109,42 +86,31 @@ int main(int ac, char **av) "%ld", TEST_RETURN); } } - cleanup(); - return EXIT_SUCCESS; + cleanup(); + tst_exit(); } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { - /* Switch to nobody user for correct error code collection */ - if (geteuid() != 0) { - tst_brkm(TBROK, NULL, "Test must be run as root"); - } + tst_require_root(NULL); + 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"); - } + if (ltpuser == NULL) + tst_brkm(TBROK, cleanup, "getpwnam failed for user id %s", + nobody_uid); + + if (setuid(ltpuser->pw_uid) == -1) + tst_resm(TINFO | TERRNO, + "setuid failed to set the effective uid to %d", + ltpuser->pw_uid); tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; - } diff --git a/testcases/kernel/syscalls/setfsuid/setfsuid01.c b/testcases/kernel/syscalls/setfsuid/setfsuid01.c index 0fa1629..0f1828e 100644 --- a/testcases/kernel/syscalls/setfsuid/setfsuid01.c +++ b/testcases/kernel/syscalls/setfsuid/setfsuid01.c @@ -1,62 +1,40 @@ /* + * Copyright (c) International Business Machines Corp., 2001 + * Ported by Wayne Boyer * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * NAME - * setfsuid01.c - * - * DESCRIPTION - * Testcase to test the basic functionality of the setfsuid(2) system - * call. - * - * ALGORITHM - * Call setfsuid(2) and test the uid returned by setfsuid(2). - * If the returned value doesn't match the uid of the process, - * then the testcase fails. - * - * USAGE: <for command-line> - * setfsuid01 [-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 + * Testcase to test the basic functionality of the setfsuid(2) system call. */ + #include <sys/types.h> #include <sys/fsuid.h> #include <stdio.h> #include <unistd.h> #include <errno.h> + #include "test.h" #include "usctest.h" +#include "compat_16.h" -void setup(void); -void cleanup(void); +static void setup(void); +static void cleanup(void); -char *TCID = "setfsuid01"; +TCID_DEFINE(setfsuid01); int TST_TOTAL = 1; int main(int ac, char **av) @@ -66,30 +44,28 @@ int main(int ac, char **av) uid_t uid; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } setup(); uid = geteuid(); + UID16_CHECK(uid, setfsuid, cleanup); - /* 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(setfsuid(uid)); + TEST(SETFSUID(cleanup, uid)); if (TEST_RETURN == -1) { - tst_resm(TFAIL, "call failed unexpectedly - errno %d", - TEST_ERRNO); + tst_resm(TFAIL | TTERRNO, + "setfsuid() failed unexpectedly"); continue; } if (!STD_FUNCTIONAL_TEST) { - tst_resm(TPASS, "call succeeded"); + tst_resm(TPASS, "setfsuid() succeeded"); continue; } @@ -97,36 +73,24 @@ int main(int ac, char **av) tst_resm(TFAIL, "setfsuid() returned %ld, expected %d", TEST_RETURN, uid); } else { - tst_resm(TPASS, "setfsuid() returned expected value : " - "%d", uid); + tst_resm(TPASS, + "setfsuid() returned expected value : %ld", + TEST_RETURN); } } + cleanup(); tst_exit(); - tst_exit(); - } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; } diff --git a/testcases/kernel/syscalls/setfsuid/setfsuid02.c b/testcases/kernel/syscalls/setfsuid/setfsuid02.c index dce6191..666dd32 100644 --- a/testcases/kernel/syscalls/setfsuid/setfsuid02.c +++ b/testcases/kernel/syscalls/setfsuid/setfsuid02.c @@ -1,67 +1,42 @@ /* + * Copyright (C) International Business Machines Corp., 2001 + * Ported by Wayne Boyer + * Adapted by Dustin Kirkland (k1r...@us...) * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * NAME - * setfsuid02.c - * - * DESCRIPTION - * Testcase to test the basic functionality of the setfsuid(2) system - * call to fail on invalid uid. - * - * ALGORITHM - * Call setfsuid(2) and test the uid returned by setfsuid(2) when - * an invalid uid is used. - * If the returned value matches the invalid uid of the process, - * then the testcase fails. - * - * USAGE: <for command-line> - * setfsuid01 [-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 - * 04/2003 Adapted by Dustin Kirkland (k1r...@us...) - * - * RESTRICTIONS - * None + * Testcase to test the basic functionality of the setfsuid(2) system + * call to fail on invalid uid. */ + #include <stdio.h> #include <unistd.h> #include <pwd.h> -#ifdef __GLIBC__ -#include <sys/fsuid.h> -#endif #include <sys/types.h> #include <errno.h> + #include "test.h" #include "usctest.h" +#include "compat_16.h" -void setup(void); -void cleanup(void); +static void setup(void); +static void cleanup(void); -char *TCID = "setfsuid02"; +TCID_DEFINE(setfsuid02); int TST_TOTAL = 1; int main(int ac, char **av) @@ -71,33 +46,31 @@ int main(int ac, char **av) uid_t uid; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } setup(); uid = 1; - while (getpwuid(uid)) { + while (getpwuid(uid)) uid++; - } - /* Check for looping state if -i option is given */ + UID16_CHECK(uid, setfsuid, cleanup); + for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset tst_count in case we are looping */ tst_count = 0; - TEST(setfsuid(uid)); + TEST(SETFSUID(cleanup, uid)); if (TEST_RETURN == -1) { - tst_resm(TFAIL, "call failed unexpectedly - errno %d", - TEST_ERRNO); + tst_resm(TFAIL | TTERRNO, + "setfsuid() failed unexpectedly"); continue; } if (!STD_FUNCTIONAL_TEST) { - tst_resm(TPASS, "call succeeded"); + tst_resm(TPASS, "setfsuid() succeeded"); continue; } @@ -109,32 +82,19 @@ int main(int ac, char **av) "%ld", TEST_RETURN); } } + cleanup(); tst_exit(); - tst_exit(); - } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; } diff --git a/testcases/kernel/syscalls/setfsuid/setfsuid03.c b/testcases/kernel/syscalls/setfsuid/setfsuid03.c index ecd9381..b194f00 100644 --- a/testcases/kernel/syscalls/setfsuid/setfsuid03.c +++ b/testcases/kernel/syscalls/setfsuid/setfsuid03.c @@ -1,69 +1,46 @@ /* + * Copyright (C) International Business Machines Corp., 2001 + * Ported by Wayne Boyer + * Adapted by Dustin Kirkland (k1r...@us...) * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * NAME - * setfsuid03.c - * - * DESCRIPTION - * Testcase to test the basic functionality of the setfsuid(2) system - * call when called by a user other than root. - * - * ALGORITHM - * Call setfsuid(2) and test the uid returned by setfsuid(2). - * If the action are allowed, - * then the testcase fails. - * - * USAGE: <for command-line> - * setfsuid01 [-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 - * 04/2003 Adapted by Dustin Kirkland (k1r...@us...) - * - * RESTRICTIONS - * None + * Testcase to test the basic functionality of the setfsuid(2) system + * call when called by a user other than root. */ + #include <stdio.h> #include <unistd.h> -#ifdef __GLIBC__ -#include <sys/fsuid.h> -#endif #include <sys/types.h> #include <errno.h> +#include <pwd.h> + #include "test.h" #include "usctest.h" -#include <pwd.h> +#include "compat_16.h" -void setup(void); -void cleanup(void); +static void setup(void); +static void cleanup(void); -char *TCID = "setfsuid03"; +TCID_DEFINE(setfsuid03); int TST_TOTAL = 1; -char nobody_uid[] = "nobody"; -struct passwd *ltpuser; + +static char nobody_uid[] = "nobody"; +static struct passwd *ltpuser; int main(int ac, char **av) { @@ -72,34 +49,31 @@ int main(int ac, char **av) uid_t uid; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } setup(); - uid = geteuid(); uid = 1; - while (!getpwuid(uid)) { + while (!getpwuid(uid)) uid++; - } - /* Check for looping state if -i option is given */ + UID16_CHECK(uid, setfsuid, cleanup); + for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset tst_count in case we are looping */ tst_count = 0; - TEST(setfsuid(uid)); + TEST(SETFSUID(cleanup, uid)); if (TEST_RETURN == -1) { - tst_resm(TFAIL, "call failed unexpectedly - errno %d", - TEST_ERRNO); + tst_resm(TFAIL | TTERRNO, + "setfsuid() failed unexpectedly"); continue; } if (!STD_FUNCTIONAL_TEST) { - tst_resm(TPASS, "call succeeded"); + tst_resm(TPASS, "setfsuid() succeeded"); continue; } @@ -112,42 +86,30 @@ int main(int ac, char **av) "%ld", TEST_RETURN); } } + cleanup(); tst_exit(); - tst_exit(); - } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { - /* Switch to nobody user for correct error code collection */ - if (geteuid() != 0) { - tst_brkm(TBROK, NULL, "Test must be run as root"); - } + tst_require_root(NULL); + ltpuser = getpwnam(nobody_uid); - if (setuid(ltpuser->pw_uid) == -1) { - tst_resm(TINFO, "setuid failed to " + if (ltpuser == NULL) + tst_brkm(TBROK, cleanup, "getpwnam failed for user id %s", + nobody_uid); + + if (setuid(ltpuser->pw_uid) == -1) + tst_resm(TINFO | TERRNO, "setuid failed to " "to set the effective uid to %d", ltpuser->pw_uid); - perror("setuid"); - } tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; } diff --git a/testcases/kernel/syscalls/setfsuid/setfsuid04.c b/testcases/kernel/syscalls/setfsuid/setfsuid04.c index 4ee2e22..0b41426 100644 --- a/testcases/kernel/syscalls/setfsuid/setfsuid04.c +++ b/testcases/kernel/syscalls/setfsuid/setfsuid04.c @@ -1,52 +1,32 @@ -/******************************************************************************/ -/* Copyright (c) Kerlabs 2008. */ -/* Copyright (c) International Business Machines Corp., 2008 */ -/* */ -/* This program is free software; you can redistribute it and/or modify */ -/* it under the terms of the GNU General Public License as published by */ -/* the Free Software Foundation; either version 2 of the License, or */ -/* (at your option) any later version. */ -/* */ -/* This program is distributed in the hope that it will be useful, */ -/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ -/* the GNU General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU General Public License */ -/* along with this program; if not, write to the Free Software */ -/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* */ -/******************************************************************************/ +/***************************************************************************** + * Copyright (c) Kerlabs 2008. * + * Copyright (c) International Business Machines Corp., 2008 * + * Created by Renaud Lottiaux * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See * + * the GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation, * + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + *****************************************************************************/ + /* - * NAME - * setfsuid04.c - * - * DESCRIPTION - * Check if setfsuid behaves correctly with file permissions. - * The test creates a file as ROOT with permissions 0644, does a setfsuid - * and then tries to open the file with RDWR permissions. - * The same test is done in a fork to check if new UIDs are correctly - * passed to the son. - * - * USAGE: <for command-line> - * setfsuid04 [-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 Created by Renaud Lottiaux - * - * RESTRICTIONS - * Must be run as root. + * Check if setfsuid behaves correctly with file permissions. + * The test creates a file as ROOT with permissions 0644, does a setfsuid + * and then tries to open the file with RDWR permissions. + * The same test is done in a fork to check if new UIDs are correctly + * passed to the son. */ + #include <sys/types.h> -#ifdef __GLIBC__ -#include <sys/fsuid.h> -#endif #include <sys/stat.h> #include <sys/wait.h> #include <errno.h> @@ -56,22 +36,23 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> + #include "test.h" #include "usctest.h" +#include "compat_16.h" -char *TCID = "setfsuid04"; +TCID_DEFINE(setfsuid04); int TST_TOTAL = 1; -char nobody_uid[] = "nobody"; -char testfile[256] = ""; -struct passwd *ltpuser; -int exp_enos[] = { EACCES, 0 }; +static char nobody_uid[] = "nobody"; +static char testfile[] = "setfsuid04_testfile"; +static struct passwd *ltpuser; -int fd = -1; +static int fd = -1; -void setup(void); -void cleanup(void); -void do_master_child(); +static void setup(void); +static void cleanup(void); +static void do_master_child(void); int main(int ac, char **av) { @@ -84,8 +65,6 @@ int main(int ac, char **av) setup(); - TEST_EXP_ENOS(exp_enos); - pid = FORK_OR_VFORK(); if (pid < 0) tst_brkm(TBROK, cleanup, "Fork failed"); @@ -97,21 +76,19 @@ int main(int ac, char **av) tst_resm(TBROK | TERRNO, "waitpid failed"); if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) tst_resm(TFAIL, "child process terminated abnormally"); + else + tst_resm(TPASS, "Test passed"); cleanup(); tst_exit(); } -/* - * do_master_child() - */ -void do_master_child() +static void do_master_child(void) { int pid; int status; - int tst_fd; - if (setfsuid(ltpuser->pw_uid) == -1) { + if (SETFSUID(NULL, ltpuser->pw_uid) == -1) { perror("setfsuid failed"); exit(1); } @@ -119,18 +96,18 @@ void do_master_child() /* Test 1: Check the process with new uid cannot open the file * with RDWR permissions. */ - tst_fd = open(testfile, O_RDWR); + TEST(open(testfile, O_RDWR)); - if (tst_fd != -1) { - printf("open succeeded unexpectedly"); - close(tst_fd); + if (TEST_RETURN != -1) { + close(TEST_RETURN); + printf("open succeeded unexpectedly\n"); exit(1); } - if (errno == EACCES) - printf("open failed with EACCES as expected"); - else { - perror("open failed unexpectedly"); + if (TEST_ERRNO == EACCES) { + printf("open failed with EACCESS as expected\n"); + } else { + printf("open returned unexpected errno - %d\n", TEST_ERRNO); exit(1); } @@ -138,25 +115,26 @@ void do_master_child() * with RDWR permissions. */ pid = FORK_OR_VFORK(); - if (pid < 0) - tst_brkm(TBROK, cleanup, "Fork failed"); + if (pid < 0) { + perror("Fork failed"); + exit(1); + } if (pid == 0) { - int tst_fd2; - /* Test to open the file in son process */ - tst_fd2 = open(testfile, O_RDWR); + TEST(open(testfile, O_RDWR)); - if (tst_fd2 != -1) { - printf("call succeeded unexpectedly\n"); - close(tst_fd2); + if (TEST_RETURN != -1) { + close(TEST_RETURN); + printf("open succeeded unexpectedly\n"); exit(1); } - if (errno == EACCES) - printf("open failed with EACCES as expected\n"); - else { - printf("open failed unexpectedly\n"); + if (TEST_ERRNO == EACCES) { + printf("open failed with EACCESS as expected\n"); + } else { + printf("open returned unexpected errno - %d\n", + TEST_ERRNO); exit(1); } } else { @@ -165,6 +143,7 @@ void do_master_child() perror("waitpid failed"); exit(1); } + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) exit(WEXITSTATUS(status)); } @@ -173,35 +152,35 @@ void do_master_child() * the file with RDWR permissions. */ tst_count++; - if (setfsuid(0) == -1) { + if (SETFSUID(NULL, 0) == -1) { perror("setfsuid failed"); exit(1); } - tst_fd = open(testfile, O_RDWR); + TEST(open(testfile, O_RDWR)); - if (tst_fd == -1) { + if (TEST_RETURN == -1) { perror("open failed unexpectedly"); exit(1); } else { - printf("open call succeeded"); - close(tst_fd); + printf("open call succeeded\n"); + close(TEST_RETURN); } exit(0); } -/* - * setup() - performs all ONE TIME setup for this test - */ -void setup(void) +static void setup(void) { tst_require_root(NULL); ltpuser = getpwnam(nobody_uid); + if (ltpuser == NULL) + tst_brkm(TBROK, cleanup, "getpwnam failed for user id %s", + nobody_uid); - tst_tmpdir(); + UID16_CHECK(ltpuser->pw_uid, setfsuid, cleanup); - sprintf(testfile, "setfsuid04file%d.tst", getpid()); + tst_tmpdir(); /* Create test file */ fd = open(testfile, O_CREAT | O_RDWR, 0644); @@ -213,20 +192,10 @@ void setup(void) TEST_PAUSE; } -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit - */ -void cleanup(void) +static void cleanup(void) { close(fd); - - /* - * print timing status if that option was specified - * print errno log if that option was specified - */ - TEST_CLEANUP; - tst_rmdir(); + TEST_CLEANUP; } diff --git a/testcases/kernel/syscalls/utils/compat_16.h b/testcases/kernel/syscalls/utils/compat_16.h index 2fdb6dc..fa1217d 100644 --- a/testcases/kernel/syscalls/utils/compat_16.h +++ b/testcases/kernel/syscalls/utils/compat_16.h @@ -24,6 +24,9 @@ #include <errno.h> #include <grp.h> +#ifdef __GLIBC__ +#include <sys/fsuid.h> +#endif #include <sys/types.h> #include <unistd.h> @@ -103,4 +106,14 @@ GID_T GETEGID(void (cleanup)(void)) { LTP_CREATE_SYSCALL(getegid, cleanup); } + +int SETFSUID(void (cleanup)(void), UID_T uid) +{ + LTP_CREATE_SYSCALL(setfsuid, cleanup, uid); +} + +int SETFSGID(void (cleanup)(void), GID_T gid) +{ + LTP_CREATE_SYSCALL(setfsgid, cleanup, gid); +} #endif /* __LTP_COMPAT_16_H__ */ hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-09-13 11:51:17
|
The branch, master, has been updated via 3a7395c6a04622a848e472426ab28ecc13a81b6b (commit) from 565f46aaa29bc58d9fec4f62e5782d075969f2a0 (commit) - Log ----------------------------------------------------------------- commit 3a7395c6a04622a848e472426ab28ecc13a81b6b Author: Vinson Lee <vl...@tw...> Date: Thu Sep 12 13:24:39 2013 -0700 setgid03.c: fix build This patch fixes build errors introduced with commit 7dc42c97696f135e1fef92e612ecc66bf8d74318. setgid03.c:36:23: error: static declaration of âgetpwnamâ follows non-static declaration In file included from setgid03.c:24:0: /usr/include/pwd.h:117:23: note: previous declaration of âgetpwnamâ was here setgid03.c:39:1: error: duplicate âstaticâ setgid03.c:40:1: error: duplicate âstaticâ Signed-off-by: Vinson Lee <vl...@tw...> Signed-off-by: Zhouping Liu <zl...@re...> Signed-off-by: Jan Stancek <jst...@re...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/setgid/setgid03.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/testcases/kernel/syscalls/setgid/setgid03.c b/testcases/kernel/syscalls/setgid/setgid03.c index 8b71401..8c76556 100644 --- a/testcases/kernel/syscalls/setgid/setgid03.c +++ b/testcases/kernel/syscalls/setgid/setgid03.c @@ -33,11 +33,11 @@ int TST_TOTAL = 1; static char ltpuser1[] = "nobody"; static char root[] = "root"; -static struct passwd *getpwnam(), *ltpuser1pwent, *rootpwent; +static struct passwd *ltpuser1pwent, *rootpwent; static gid_t mygid; -static static void setup(void); -static static void cleanup(void); +static void setup(void); +static void cleanup(void); int main(int ac, char **av) { hooks/post-receive -- ltp |
From: Cyril H. <su...@li...> - 2013-09-12 13:51:30
|
The branch, master, has been updated via 565f46aaa29bc58d9fec4f62e5782d075969f2a0 (commit) via 61e3e02a1b230a02d864d1fb6969ba2b8efe0cab (commit) via 4940d00b75ec0f7a375dce5542afd56cfc0267f0 (commit) via 3875344caeeaec34826929a1708ce73e58c0e862 (commit) via 7dc42c97696f135e1fef92e612ecc66bf8d74318 (commit) via 1c44244849cee68dec5f38a61a3441b0e0a3b472 (commit) via e1f32ce1ff8f7038806c9565d6dd9c1c8644b51e (commit) from 372fbd2416fd02b205690443f93e609c462b409e (commit) - Log ----------------------------------------------------------------- commit 565f46aaa29bc58d9fec4f62e5782d075969f2a0 Author: Cyril Hrubis <ch...@su...> Date: Thu Sep 12 15:39:10 2013 +0200 device-drivers/rtc: Fix .gitignore I forget to fix it when the test was renamed. Signed-off-by: Cyril Hrubis <ch...@su...> commit 61e3e02a1b230a02d864d1fb6969ba2b8efe0cab Author: Cyril Hrubis <ch...@su...> Date: Thu Sep 12 15:37:26 2013 +0200 syscalls: get{egid, euid} Cleanup. Remove useless comments, decleare local vars static, etc. Signed-off-by: Cyril Hrubis <ch...@su...> commit 4940d00b75ec0f7a375dce5542afd56cfc0267f0 Author: Stanislav Kholmanskikh <sta...@or...> Date: Wed Sep 11 13:25:44 2013 +0400 getegid, geteuid: fixed 16-bit versions Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit 3875344caeeaec34826929a1708ce73e58c0e862 Author: Cyril Hrubis <ch...@su...> Date: Thu Sep 12 14:58:41 2013 +0200 syscalls: setuid04: Make use of tst_{tmpdir,rmdir} Signed-off-by: Cyril Hrubis <ch...@su...> commit 7dc42c97696f135e1fef92e612ecc66bf8d74318 Author: Cyril Hrubis <ch...@su...> Date: Thu Sep 12 14:55:55 2013 +0200 syscalls: {set,get}{gid,uid}: Cleanup. Remove useless comments, decleare local vars static, etc. Signed-off-by: Cyril Hrubis <ch...@su...> commit 1c44244849cee68dec5f38a61a3441b0e0a3b472 Author: Stanislav Kholmanskikh <sta...@or...> Date: Wed Sep 11 13:25:43 2013 +0400 getuid, getgid, setuid, setgid: fixed 16-bit versions Fixed 16-bit versions of testcases: * getgid * getuid * setgid * setuid the way like setgroups. Testcase getuid02 in fact tests geteuid() so renamed it to geteuid02. Signed-off-by: Stanislav Kholmanskikh <sta...@or...> commit e1f32ce1ff8f7038806c9565d6dd9c1c8644b51e Author: Cyril Hrubis <ch...@su...> Date: Wed Sep 11 11:48:01 2013 +0200 runtest/mm: Fix ksn -> ksm typo. Signed-off-by: Cyril Hrubis <ch...@su...> Acked-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: runtest/ltplite | 2 +- runtest/mm | 2 +- runtest/stress.part3 | 2 +- runtest/syscalls | 4 +- testcases/kernel/device-drivers/rtc/.gitignore | 2 +- testcases/kernel/syscalls/.gitignore | 4 +- testcases/kernel/syscalls/getegid/compat_16.h | 48 ------- testcases/kernel/syscalls/getegid/getegid01.c | 96 +------------ testcases/kernel/syscalls/getegid/getegid02.c | 128 +++++------------- testcases/kernel/syscalls/geteuid/compat_16.h | 48 ------- testcases/kernel/syscalls/geteuid/geteuid01.c | 96 +------------ .../getitimer01.c => geteuid/geteuid02.c} | 83 +++++------- testcases/kernel/syscalls/getgid/compat_16.h | 60 -------- testcases/kernel/syscalls/getgid/getgid01.c | 95 ++------------ testcases/kernel/syscalls/getgid/getgid03.c | 128 +++++------------- testcases/kernel/syscalls/getuid/compat_16.h | 60 -------- testcases/kernel/syscalls/getuid/getuid01.c | 95 ++------------ testcases/kernel/syscalls/getuid/getuid02.c | 112 --------------- testcases/kernel/syscalls/getuid/getuid03.c | 92 +++++-------- testcases/kernel/syscalls/setgid/compat_16.h | 68 ---------- testcases/kernel/syscalls/setgid/setgid01.c | 136 ++----------------- testcases/kernel/syscalls/setgid/setgid02.c | 113 +++++----------- testcases/kernel/syscalls/setgid/setgid03.c | 105 ++++----------- testcases/kernel/syscalls/setuid/setuid01.c | 142 ++----------------- testcases/kernel/syscalls/setuid/setuid02.c | 14 +-- testcases/kernel/syscalls/setuid/setuid03.c | 101 +++++--------- testcases/kernel/syscalls/setuid/setuid04.c | 138 +++++++------------ testcases/kernel/syscalls/utils/compat_16.h | 49 +++++++ 28 files changed, 414 insertions(+), 1609 deletions(-) delete mode 100644 testcases/kernel/syscalls/getegid/compat_16.h delete mode 100644 testcases/kernel/syscalls/geteuid/compat_16.h copy testcases/kernel/syscalls/{getitimer/getitimer01.c => geteuid/geteuid02.c} (55%) delete mode 100644 testcases/kernel/syscalls/getgid/compat_16.h delete mode 100644 testcases/kernel/syscalls/getuid/compat_16.h delete mode 100644 testcases/kernel/syscalls/getuid/getuid02.c delete mode 100644 testcases/kernel/syscalls/setgid/compat_16.h diff --git a/runtest/ltplite b/runtest/ltplite index 2a704db..8ff55ee 100644 --- a/runtest/ltplite +++ b/runtest/ltplite @@ -285,6 +285,7 @@ getdtablesize01 getdtablesize01 getegid01 getegid01 geteuid01 geteuid01 +geteuid02 geteuid02 getgid01 getgid01 getgid03 getgid03 @@ -341,7 +342,6 @@ gettimeofday01 gettimeofday01 gettimeofday02 gettimeofday02 getuid01 getuid01 -getuid02 getuid02 getuid03 getuid03 #Needs tty device. diff --git a/runtest/mm b/runtest/mm index a39becd..28151b5 100644 --- a/runtest/mm +++ b/runtest/mm @@ -72,7 +72,7 @@ ksm04_1 ksm04 -u 128 ksm05 ksm05 -I 10 ksm06 ksm06 ksm06_1 ksm06 -n 10 -ksn06_2 ksm06 -n 10000 +ksm06_2 ksm06 -n 10000 cpuset01 cpuset01 -I 3600 diff --git a/runtest/stress.part3 b/runtest/stress.part3 index b783b7f..0533d4d 100644 --- a/runtest/stress.part3 +++ b/runtest/stress.part3 @@ -224,6 +224,7 @@ getdtablesize01 getdtablesize01 getegid01 getegid01 geteuid01 geteuid01 +geteuid02 geteuid02 getgid01 getgid01 getgid03 getgid03 @@ -281,7 +282,6 @@ gettimeofday01 gettimeofday01 gettimeofday02 gettimeofday02 getuid01 getuid01 -getuid02 getuid02 getuid03 getuid03 ioperm01 ioperm01 diff --git a/runtest/syscalls b/runtest/syscalls index b778b64..09e5f7f 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -343,6 +343,8 @@ getegid02_16 getegid02_16 geteuid01 geteuid01 geteuid01_16 geteuid01_16 +geteuid02 geteuid02 +geteuid02_16 geteuid02_16 getgid01 getgid01 getgid01_16 getgid01_16 @@ -413,8 +415,6 @@ gettimeofday02 gettimeofday02 getuid01 getuid01 getuid01_16 getuid01_16 -getuid02 getuid02 -getuid02_16 getuid02_16 getuid03 getuid03 getuid03_16 getuid03_16 diff --git a/testcases/kernel/device-drivers/rtc/.gitignore b/testcases/kernel/device-drivers/rtc/.gitignore index 727656a..8412fe6 100644 --- a/testcases/kernel/device-drivers/rtc/.gitignore +++ b/testcases/kernel/device-drivers/rtc/.gitignore @@ -1 +1 @@ -/rtc-test +/rtc01 diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore index f8f02d5..ad23c2e 100644 --- a/testcases/kernel/syscalls/.gitignore +++ b/testcases/kernel/syscalls/.gitignore @@ -286,6 +286,8 @@ /getegid/getegid02_16 /geteuid/geteuid01 /geteuid/geteuid01_16 +/geteuid/geteuid02 +/geteuid/geteuid02_16 /getgid/getgid01 /getgid/getgid01_16 /getgid/getgid03 @@ -336,8 +338,6 @@ /gettimeofday/gettimeofday02 /getuid/getuid01 /getuid/getuid01_16 -/getuid/getuid02 -/getuid/getuid02_16 /getuid/getuid03 /getuid/getuid03_16 /getxattr/getxattr01 diff --git a/testcases/kernel/syscalls/getegid/compat_16.h b/testcases/kernel/syscalls/getegid/compat_16.h deleted file mode 100644 index a28289b..0000000 --- a/testcases/kernel/syscalls/getegid/compat_16.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Copyright (c) Red Hat Inc., 2008 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Author: Masatake YAMATO <ya...@re...> */ - -#ifndef __GETEGID_COMPAT_16_H__ -#define __GETEGID_COMPAT_16_H__ - - -#include "linux_syscall_numbers.h" -#include "compat_gid.h" - - -#ifdef TST_USE_COMPAT16_SYSCALL - -GID_T -GETEGID(void) -{ - return ltp_syscall(__NR_getegid); -} - -#else - -GID_T -GETEGID(void) -{ - return getegid(); -} - -#endif - -#endif /* __GETEGID_COMPAT_16_H__ */ diff --git a/testcases/kernel/syscalls/getegid/getegid01.c b/testcases/kernel/syscalls/getegid/getegid01.c index 3b4f17e..6c10b42 100644 --- a/testcases/kernel/syscalls/getegid/getegid01.c +++ b/testcases/kernel/syscalls/getegid/getegid01.c @@ -30,82 +30,11 @@ * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ * */ -/* $Id: getegid01.c,v 1.8 2009/10/26 14:55:47 subrata_modak Exp $ */ -/********************************************************** - * - * 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 <sys/types.h> #include <errno.h> @@ -114,17 +43,14 @@ #include "test.h" #include "usctest.h" - #include "compat_16.h" -void setup(); -void cleanup(); +static void setup(); +static void cleanup(); TCID_DEFINE(getegid01); int TST_TOTAL = 1; -int exp_enos[] = { 0 }; /* must be a 0 terminated list */ - int main(int ac, char **av) { int lc; @@ -135,13 +61,11 @@ int main(int ac, char **av) setup(); - TEST_EXP_ENOS(exp_enos); - for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; - TEST(GETEGID()); + TEST(GETEGID(cleanup)); if (TEST_RETURN == -1) { tst_resm(TFAIL | TTERRNO, "getegid failed"); @@ -154,20 +78,16 @@ int main(int ac, char **av) } cleanup(); - tst_exit(); } -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); - TEST_PAUSE; } -void cleanup() +static void cleanup(void) { TEST_CLEANUP; - } diff --git a/testcases/kernel/syscalls/getegid/getegid02.c b/testcases/kernel/syscalls/getegid/getegid02.c index e8b4022..c848d53 100644 --- a/testcases/kernel/syscalls/getegid/getegid02.c +++ b/testcases/kernel/syscalls/getegid/getegid02.c @@ -1,62 +1,27 @@ /* + * Copyright (c) International Business Machines Corp., 2001 + * Ported by Wayne Boyer * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * NAME - * getegid02.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: <for command-line> - * getegid02 [-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 + * Testcase to check the basic functionality of getegid(). * - * RESTRICTIONS - * none + * For functionality test the return value from getegid() is compared to passwd + * entry. */ #include <pwd.h> @@ -64,11 +29,10 @@ #include "test.h" #include "usctest.h" - #include "compat_16.h" -void cleanup(void); -void setup(void); +static void cleanup(void); +static void setup(void); TCID_DEFINE(getegid02); int TST_TOTAL = 1; @@ -77,21 +41,18 @@ int main(int ac, char **av) { int lc; char *msg; - int euid; + uid_t euid; struct passwd *pwent; if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - setup(); /* 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; - TEST(GETEGID()); + TEST(GETEGID(cleanup)); if (TEST_RETURN < 0) { tst_brkm(TBROK, cleanup, "This should never happen"); @@ -99,58 +60,39 @@ int main(int ac, char **av) if (STD_FUNCTIONAL_TEST) { euid = geteuid(); - pwent = getpwuid(euid); - if (pwent == NULL) { + if (pwent == NULL) tst_brkm(TBROK, cleanup, "geteuid() returned " "unexpected value %d", euid); - } else if (!GID_SIZE_CHECK(pwent->pw_gid)) { - tst_brkm(TBROK, - cleanup, - "gid for euid %d is too large for testing getegid16", - euid); + + GID16_CHECK(pwent->pw_gid, getegid, cleanup); + + if (pwent->pw_gid != TEST_RETURN) { + tst_resm(TFAIL, "getegid() return value" + " %ld unexpected - expected %d", + TEST_RETURN, pwent->pw_gid); } else { - if (pwent->pw_gid != TEST_RETURN) { - tst_resm(TFAIL, "getegid() return value" - " %ld unexpected - expected %d", - TEST_RETURN, pwent->pw_gid); - } else { - tst_resm(TPASS, - "effective group id %ld " - "is correct", TEST_RETURN); - } + tst_resm(TPASS, + "effective group id %ld " + "is correct", TEST_RETURN); } } else { tst_resm(TPASS, "call succeeded"); } } - cleanup(); + cleanup(); tst_exit(); } -/* - * setup() - performs all ONE TIME setup for this test - */ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); - TEST_PAUSE; } -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ TEST_CLEANUP; - } diff --git a/testcases/kernel/syscalls/geteuid/compat_16.h b/testcases/kernel/syscalls/geteuid/compat_16.h deleted file mode 100644 index 9436cd5..0000000 --- a/testcases/kernel/syscalls/geteuid/compat_16.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Copyright (c) Red Hat Inc., 2009 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Author: Masatake YAMATO <ya...@re...> */ - -#ifndef __GETUID_COMPAT_16_H__ -#define __GETUID_COMPAT_16_H__ - - -#include "linux_syscall_numbers.h" -#include "compat_uid.h" - - -#ifdef TST_USE_COMPAT16_SYSCALL - -UID_T -GETEUID(void) -{ - return ltp_syscall(__NR_geteuid); -} - -#else - -UID_T -GETEUID(void) -{ - return geteuid(); -} - -#endif - -#endif /* __GETUID_COMPAT_16_H__ */ diff --git a/testcases/kernel/syscalls/geteuid/geteuid01.c b/testcases/kernel/syscalls/geteuid/geteuid01.c index 15d9a32..d6505b8 100644 --- a/testcases/kernel/syscalls/geteuid/geteuid01.c +++ b/testcases/kernel/syscalls/geteuid/geteuid01.c @@ -30,82 +30,11 @@ * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ * */ -/* $Id: geteuid01.c,v 1.7 2009/10/26 16:02:46 subrata_modak Exp $ */ -/********************************************************** - * - * 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 <sys/types.h> #include <errno.h> @@ -114,17 +43,14 @@ #include "test.h" #include "usctest.h" - #include "compat_16.h" -void setup(); -void cleanup(); +static void setup(void); +static void cleanup(void); TCID_DEFINE(geteuid01); int TST_TOTAL = 1; -int exp_enos[] = { 0 }; /* must be a 0 terminated list */ - int main(int ac, char **av) { int lc; @@ -135,13 +61,11 @@ int main(int ac, char **av) setup(); - TEST_EXP_ENOS(exp_enos); - for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; - TEST(GETEUID()); + TEST(GETEUID(cleanup)); if (TEST_RETURN < 0) { tst_resm(TFAIL | TTERRNO, "geteuid failed"); @@ -153,20 +77,16 @@ int main(int ac, char **av) } cleanup(); - tst_exit(); } -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); - TEST_PAUSE; } -void cleanup() +static void cleanup(void) { TEST_CLEANUP; - } diff --git a/testcases/kernel/syscalls/getitimer/getitimer01.c b/testcases/kernel/syscalls/geteuid/geteuid02.c similarity index 55% copy from testcases/kernel/syscalls/getitimer/getitimer01.c copy to testcases/kernel/syscalls/geteuid/geteuid02.c index 5569a49..cf25621 100644 --- a/testcases/kernel/syscalls/getitimer/getitimer01.c +++ b/testcases/kernel/syscalls/geteuid/geteuid02.c @@ -1,5 +1,6 @@ /* * Copyright (c) International Business Machines Corp., 2001 + * Ported by Wayne Boyer * * 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 @@ -16,41 +17,27 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* - HISTORY - 03/2001 - Written by Wayne Boyer - - TEST ITEMS: - Check that a correct call to getitimer() succeeds. -*/ +#include <pwd.h> +#include <errno.h> #include "test.h" #include "usctest.h" +#include "compat_16.h" -#include <errno.h> -#include <sys/time.h> +TCID_DEFINE(geteuid02); +int TST_TOTAL = 1; -static void cleanup(void); static void setup(void); - -char *TCID = "getitimer01"; -int TST_TOTAL = 3; - -static int itimer_name[] = { - ITIMER_REAL, - ITIMER_VIRTUAL, - ITIMER_PROF, -}; +static void cleanup(void); int main(int ac, char **av) { + struct passwd *pwent; int lc; - int i; char *msg; - struct itimerval value; + uid_t uid; - msg = parse_opts(ac, av, NULL, NULL); - if (msg != NULL) + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); setup(); @@ -58,42 +45,38 @@ int main(int ac, char **av) for (lc = 0; TEST_LOOPING(lc); lc++) { tst_count = 0; - for (i = 0; i < 3; i++) { - - TEST(getitimer(itimer_name[i], &value)); - - if (TEST_RETURN != 0) - tst_resm(TFAIL, "call failed - errno = %d - %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - - if (STD_FUNCTIONAL_TEST) { - - /* - * Since ITIMER is effectively disabled (we did - * not set it before the getitimer call), the - * elements in it_value should be zero. - */ - if ((value.it_value.tv_sec == 0) && - (value.it_value.tv_usec == 0)) { - tst_resm(TPASS, "functionality is ok"); - } else { - tst_resm(TFAIL, "timer are non zero"); - } - } else { - tst_resm(TPASS, "call succeeded"); - } - } + TEST(GETEUID(cleanup)); + + if (TEST_RETURN == -1) + tst_brkm(TBROK | TTERRNO, cleanup, "geteuid* failed"); + + if (STD_FUNCTIONAL_TEST) { + uid = geteuid(); + pwent = getpwuid(uid); + + if (pwent == NULL) + tst_resm(TFAIL | TERRNO, "getpwuid failed"); + + UID16_CHECK(pwent->pw_uid, geteuid, cleanup); + if (pwent->pw_uid != TEST_RETURN) + tst_resm(TFAIL, "getpwuid value, %d, " + "does not match geteuid " + "value, %ld", pwent->pw_uid, + TEST_RETURN); + else + tst_resm(TPASS, "values from geteuid " + "and getpwuid match"); + } else + tst_resm(TPASS, "call succeeded"); } cleanup(); - tst_exit(); } static void setup(void) { tst_sig(NOFORK, DEF_HANDLER, cleanup); - TEST_PAUSE; } diff --git a/testcases/kernel/syscalls/getgid/compat_16.h b/testcases/kernel/syscalls/getgid/compat_16.h deleted file mode 100644 index 249e270..0000000 --- a/testcases/kernel/syscalls/getgid/compat_16.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Copyright (c) Red Hat Inc., 2008 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Author: Masatake YAMATO <ya...@re...> */ - -#ifndef __GETGID_COMPAT_16_H__ -#define __GETGID_COMPAT_16_H__ - - -#include "linux_syscall_numbers.h" -#include "compat_gid.h" - - -#ifdef TST_USE_COMPAT16_SYSCALL - -GID_T -GETGID(void) -{ - return ltp_syscall(__NR_getgid); -} - -GID_T -GETEGID(void) -{ - return ltp_syscall(__NR_getegid); -} - -#else - -GID_T -GETGID(void) -{ - return getgid(); -} - -GID_T -GETEGID(void) -{ - return getegid(); -} - -#endif - -#endif /* __GETGID_COMPAT_16_H__ */ diff --git a/testcases/kernel/syscalls/getgid/getgid01.c b/testcases/kernel/syscalls/getgid/getgid01.c index 07b5bcd..6e3f64b 100644 --- a/testcases/kernel/syscalls/getgid/getgid01.c +++ b/testcases/kernel/syscalls/getgid/getgid01.c @@ -30,101 +30,27 @@ * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ * */ -/* $Id: getgid01.c,v 1.7 2009/10/26 14:55:47 subrata_modak Exp $ */ -/********************************************************** - * - * OS Test - Silicon Graphics, Inc. - * - * TEST IDENTIFIER : getgid01 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Basic test for getgid(2) - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 1 - * - * WALL CLOCK TIME : 1 - * - * CPU TYPES : ALL - * +/* * AUTHOR : William Roske - * * CO-PILOT : Dave Fenner - * - * DATE STARTED : 03/30/92 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * - * 1.) getgid(2) returns...(See Description) - * - * INPUT SPECIFICATIONS - * The standard options for system call tests are accepted. - * (See the parse_opts(3) man page). - * - * OUTPUT SPECIFICATIONS - *$ - * DURATION - * Terminates - with frequency and infinite modes. - * - * SIGNALS - * Uses SIGUSR1 to pause before test if option set. - * (See the parse_opts(3) man page). - * - * RESOURCES - * None - * - * ENVIRONMENTAL NEEDS - * No run-time environmental needs. - * - * SPECIAL PROCEDURAL REQUIREMENTS - * None - * - * INTERCASE DEPENDENCIES - * None - * - * DETAILED DESCRIPTION - * This is a Phase I test for the getgid(2) system call. It is intended - * to provide a limited exposure of the system call, for now. It - * should/will be extended when full functional tests are written for - * getgid(2). - * - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Otherwise, Issue a PASS message. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * - * - *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ - + */ #include <sys/types.h> #include <sys/fcntl.h> #include <errno.h> #include <signal.h> #include <string.h> + #include "test.h" #include "usctest.h" #include "compat_16.h" -void setup(); -void cleanup(); +static void setup(void); +static void cleanup(void); TCID_DEFINE(getgid01); int TST_TOTAL = 1; -int exp_enos[] = { 0, 0 }; +static int exp_enos[] = { 0, 0 }; int main(int ac, char **av) { @@ -142,7 +68,7 @@ int main(int ac, char **av) tst_count = 0; - TEST(GETGID()); + TEST(GETGID(cleanup)); if (TEST_RETURN == -1) tst_resm(TFAIL, "getgid failed"); @@ -158,16 +84,13 @@ int main(int ac, char **av) tst_exit(); } -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); - TEST_PAUSE; } -void cleanup() +static void cleanup(void) { TEST_CLEANUP; - } diff --git a/testcases/kernel/syscalls/getgid/getgid03.c b/testcases/kernel/syscalls/getgid/getgid03.c index 35325d9..0d04ece 100644 --- a/testcases/kernel/syscalls/getgid/getgid03.c +++ b/testcases/kernel/syscalls/getgid/getgid03.c @@ -1,62 +1,27 @@ /* + * Copyright (c) International Business Machines Corp., 2001 + * Ported by Wayne Boyer * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * NAME - * getgid03.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: <for command-line> - * getgid03 [-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 + * Testcase to check the basic functionality of getgid(). * - * RESTRICTIONS - * none + * For functionality test the return value from getgid() is compared to passwd + * entry. */ #include <pwd.h> @@ -64,11 +29,10 @@ #include "test.h" #include "usctest.h" - #include "compat_16.h" -void cleanup(void); -void setup(void); +static void cleanup(void); +static void setup(void); TCID_DEFINE(getgid03); int TST_TOTAL = 1; @@ -77,22 +41,18 @@ int main(int ac, char **av) { int lc; char *msg; - int uid; + uid_t uid; struct passwd *pwent; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } - setup(); /* 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; - TEST(GETGID()); + TEST(GETGID(cleanup)); if (TEST_RETURN < 0) { tst_brkm(TBROK, cleanup, "This should never happen"); @@ -102,54 +62,36 @@ int main(int ac, char **av) uid = getuid(); pwent = getpwuid(uid); - if (pwent == NULL) { + if (pwent == NULL) tst_brkm(TBROK, cleanup, "getuid() returned " "unexpected value %d", uid); - } else if (!GID_SIZE_CHECK(pwent->pw_gid)) { - tst_brkm(TBROK, - cleanup, - "gid for uid %d is too large for testing getgid16", - uid); + + GID16_CHECK(pwent->pw_gid, getgid, cleanup); + + if (pwent->pw_gid != TEST_RETURN) { + tst_resm(TFAIL, "getgid() return value " + "%ld unexpected - expected %d", + TEST_RETURN, pwent->pw_gid); } else { - if (pwent->pw_gid != TEST_RETURN) { - tst_resm(TFAIL, "getgid() return value " - "%ld unexpected - expected %d", - TEST_RETURN, pwent->pw_gid); - } else { - tst_resm(TPASS, "group id %ld returned " - "correctly", TEST_RETURN); - } + tst_resm(TPASS, "values from getuid " + "and getpwuid match"); } } else { tst_resm(TPASS, "call succeeded"); } } - cleanup(); + cleanup(); tst_exit(); } -/* - * setup() - performs all ONE TIME setup for this test - */ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); - TEST_PAUSE; } -/* - * cleanup() - performs all the ONE TIME cleanup for this test at completion - * or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing status if that option was specified. - * print errno log if that option was specified - */ TEST_CLEANUP; - } diff --git a/testcases/kernel/syscalls/getuid/compat_16.h b/testcases/kernel/syscalls/getuid/compat_16.h deleted file mode 100644 index db6f332..0000000 --- a/testcases/kernel/syscalls/getuid/compat_16.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Copyright (c) Red Hat Inc., 2008 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Author: Masatake YAMATO <ya...@re...> */ - -#ifndef __GETUID_COMPAT_16_H__ -#define __GETUID_COMPAT_16_H__ - - -#include "linux_syscall_numbers.h" -#include "compat_uid.h" - - -#ifdef TST_USE_COMPAT16_SYSCALL - -UID_T -GETUID(void) -{ - return ltp_syscall(__NR_getuid); -} - -UID_T -GETEUID(void) -{ - return ltp_syscall(__NR_geteuid); -} - -#else - -UID_T -GETUID(void) -{ - return getuid(); -} - -UID_T -GETEUID(void) -{ - return geteuid(); -} - -#endif - -#endif /* __GETUID_COMPAT_16_H__ */ diff --git a/testcases/kernel/syscalls/getuid/getuid01.c b/testcases/kernel/syscalls/getuid/getuid01.c index 4c2d65c..a9d508f 100644 --- a/testcases/kernel/syscalls/getuid/getuid01.c +++ b/testcases/kernel/syscalls/getuid/getuid01.c @@ -28,103 +28,28 @@ * For further information regarding this notice, see: * * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ - * */ -/* $Id: getuid01.c,v 1.9 2009/10/26 14:55:47 subrata_modak Exp $ */ -/********************************************************** - * - * OS Test - Silicon Graphics, Inc. - * - * TEST IDENTIFIER : getuid01 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Basic test for getuid(2) - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 1 - * - * WALL CLOCK TIME : 1 - * - * CPU TYPES : ALL - * +/* * AUTHOR : William Roske - * * CO-PILOT : Dave Fenner - * - * DATE STARTED : 03/30/92 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * - * 1.) getuid(2) returns...(See Description) - * - * INPUT SPECIFICATIONS - * The standard options for system call tests are accepted. - * (See the parse_opts(3) man page). - * - * OUTPUT SPECIFICATIONS - *$ - * DURATION - * Terminates - with frequency and infinite modes. - * - * SIGNALS - * Uses SIGUSR1 to pause before test if option set. - * (See the parse_opts(3) man page). - * - * RESOURCES - * None - * - * ENVIRONMENTAL NEEDS - * No run-time environmental needs. - * - * SPECIAL PROCEDURAL REQUIREMENTS - * None - * - * INTERCASE DEPENDENCIES - * None - * - * DETAILED DESCRIPTION - * This is a Phase I test for the getuid(2) system call. It is intended - * to provide a limited exposure of the system call, for now. It - * should/will be extended when full functional tests are written for - * getuid(2). - * - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Otherwise, Issue a PASS message. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * - * - *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ - + */ #include <sys/types.h> #include <sys/fcntl.h> #include <errno.h> #include <string.h> #include <signal.h> + #include "test.h" #include "usctest.h" #include "compat_16.h" -void setup(); -void cleanup(); +static void setup(void); +static void cleanup(void); TCID_DEFINE(getuid01); int TST_TOTAL = 1; -int exp_enos[] = { 0, 0 }; +static int exp_enos[] = { 0, 0 }; int main(int ac, char **av) { @@ -142,7 +67,7 @@ int main(int ac, char **av) tst_count = 0; - TEST(GETUID()); + TEST(GETUID(cleanup)); if (TEST_RETURN == -1) tst_resm(TFAIL | TTERRNO, "getuid failed"); @@ -155,15 +80,13 @@ int main(int ac, char **av) tst_exit(); } -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); - TEST_PAUSE; } -void cleanup() +static void cleanup(void) { TEST_CLEANUP; } diff --git a/testcases/kernel/syscalls/getuid/getuid02.c b/testcases/kernel/syscalls/getuid/getuid02.c deleted file mode 100644 index 27a24e0..0000000 --- a/testcases/kernel/syscalls/getuid/getuid02.c +++ /dev/null @@ -1,112 +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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* - * NAME - * getuid02.c - * - * DESCRIPTION - * Testcase to check the basic functionality of the geteuid() system call. - * - * USAGE: <for command-line> - * 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 <pwd.h> -#include <errno.h> -#include "test.h" -#include "usctest.h" -#include "compat_16.h" - -TCID_DEFINE(getuid02); -int TST_TOTAL = 1; - -void setup(void); -void cleanup(void); - -int main(int ac, char **av) -{ - struct passwd *pwent; - int lc; - char *msg; /* message returned by parse_opts */ - - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - tst_count = 0; - - TEST(GETEUID()); - - if (TEST_RETURN == -1) - tst_brkm(TBROK | TTERRNO, cleanup, "geteuid* failed"); - - if (STD_FUNCTIONAL_TEST) { - - pwent = getpwuid(TEST_RETURN); - if (pwent == NULL) - tst_resm(TFAIL | TERRNO, "getpwuid failed"); - else if (!UID_SIZE_CHECK(pwent->pw_uid)) - tst_brkm(TBROK, cleanup, - "uid = %ld is too large for testing " - "via geteuid16", TEST_RETURN); - else { - if (pwent->pw_uid != TEST_RETURN) - tst_resm(TFAIL, "getpwuid value, %d, " - "does not match geteuid " - "value, %ld", pwent->pw_uid, - TEST_RETURN); - else - tst_resm(TPASS, "values from geteuid " - "and getpwuid match"); - } - } else - tst_resm(TPASS, "call succeeded"); - } - cleanup(); - tst_exit(); - -} - -void setup() -{ - - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - TEST_PAUSE; -} - -void cleanup() -{ - TEST_CLEANUP; -} diff --git a/testcases/kernel/syscalls/getuid/getuid03.c b/testcases/kernel/syscalls/getuid/getuid03.c index a5fd7f1..5240f55 100644 --- a/testcases/kernel/syscalls/getuid/getuid03.c +++ b/testcases/kernel/syscalls/getuid/getuid03.c @@ -1,47 +1,32 @@ /* + * Copyright (c) International Business Machines Corp., 2001 + * Ported by Wayne Boyer * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * NAME - * getuid03.c - * - * DESCRIPTION - * Testcase to check the basic functionality of the getuid() system call. - * - * USAGE: <for command-line> - * getuid03 [-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. + * Testcase to check the basic functionality of the getuid() system call. * - * HISTORY - * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None + * For functionality test the return value from getgid() is compared to passwd + * entry. */ #include <pwd.h> #include <errno.h> + #include "test.h" #include "usctest.h" #include "compat_16.h" @@ -49,14 +34,15 @@ TCID_DEFINE(getuid03); int TST_TOTAL = 1; -void setup(void); -void cleanup(void); +static void setup(void); +static void cleanup(void); int main(int ac, char **av) { struct passwd *pwent; int lc; - char *msg; /* message returned by parse_opts */ + char *msg; + uid_t uid; if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); @@ -67,29 +53,28 @@ int main(int ac, char **av) tst_count = 0; - TEST(GETUID()); + TEST(GETUID(cleanup)); if (TEST_RETURN == -1) tst_brkm(TBROK | TTERRNO, cleanup, "getuid failed"); if (STD_FUNCTIONAL_TEST) { - pwent = getpwuid(TEST_RETURN); + uid = getuid(); + pwent = getpwuid(uid); + if (pwent == NULL) tst_resm(TFAIL | TERRNO, "getpwuid failed"); - else if (!UID_SIZE_CHECK(pwent->pw_uid)) - tst_brkm(TBROK, cleanup, - "uid = %ld is too large for testing " - "getuid16", TEST_RETURN); - else { - if (pwent->pw_uid != TEST_RETURN) - tst_resm(TFAIL, "getpwuid value, %d, " - "does not match getuid " - "value, %ld", pwent->pw_uid, - TEST_RETURN); - else - tst_resm(TPASS, "values from getuid " - "and getpwuid match"); - } + + UID16_CHECK(pwent->pw_uid, getuid, cleanup); + + if (pwent->pw_uid != TEST_RETURN) + tst_resm(TFAIL, "getpwuid value, %d, " + "does not match getuid " + "value, %ld", pwent->pw_uid, + TEST_RETURN); + else + tst_resm(TPASS, "values from getuid " + "and getpwuid match"); } else tst_resm(TPASS, "call succeeded"); } @@ -97,15 +82,14 @@ int main(int ac, char **av) tst_exit(); } -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; } -void cleanup() +static void cleanup(void) { TEST_CLEANUP; } diff --git a/testcases/kernel/syscalls/setgid/compat_16.h b/testcases/kernel/syscalls/setgid/compat_16.h deleted file mode 100644 index 9d1d15c..0000000 --- a/testcases/kernel/syscalls/setgid/compat_16.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * - * Copyright (c) Red Hat Inc., 2008 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Author: Masatake YAMATO <ya...@re...> */ - -#ifndef __SETGID_COMPAT_16_H__ -#define __SETGID_COMPAT_16_H__ - - -#include "linux_syscall_numbers.h" -#include "compat_gid.h" - - -#ifdef TST_USE_COMPAT16_SYSCALL - -int -SETGID(GID_T gid) -{ - return ltp_syscall(__NR_setgid, gid); -} - -GID_T -GETGID(void) -{ - gid_t gid; - - gid = getgid(); - if (!GID_SIZE_CHECK(gid)) - tst_brkm(TBROK, - cleanup, - "gid for the current process is too large for testing setgid16"); - - return (GID_T)gid; -} - -#else - -int -SETGID(GID_T gid) -{ - return setgid(gid); -} - -GID_T -GETGID(void) -{ - return getgid(); -} - -#endif - -#endif /* __SETGID_COMPAT_16_H__ */ diff --git a/testcases/kernel/syscalls/setgid/setgid01.c b/testcases/kernel/syscalls/setgid/setgid01.c index 9121e47..9a701a2 100644 --- a/testcases/kernel/syscalls/setgid/setgid01.c +++ b/testcases/kernel/syscalls/setgid/setgid01.c @@ -30,143 +30,50 @@ * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ * */ -/* $Id: setgid01.c,v 1.9 2009/11/02 13:57:18 subrata_modak Exp $ */ -/********************************************************** - * - * OS Test - Silicon Graphics, Inc. - * - * TEST IDENTIFIER : setgid01 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Basic test for setgid(2) - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 1 - * - * WALL CLOCK TIME : 1 - * - * CPU TYPES : ALL - * +/* * AUTHOR : William Roske - * * CO-PILOT : Dave Fenner - * - * DATE STARTED : 03/30/92 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * - * 1.) setgid(2) returns...(See Description) - * - * INPUT SPECIFICATIONS - * The standard options for system call tests are accepted. - * (See the parse_opts(3) man page). - * - * OUTPUT SPECIFICATIONS - *$ - * DURATION - * Terminates - with frequency and infinite modes. - * - * SIGNALS - * Uses SIGUSR1 to pause before test if option set. - * (See the parse_opts(3) man page). - * - * RESOURCES - * None - * - * ENVIRONMENTAL NEEDS - * No run-time environmental needs. - * - * SPECIAL PROCEDURAL REQUIREMENTS - * None - * - * INTERCASE DEPENDENCIES - * None - * - * DETAILED DESCRIPTION - * This is a Phase I test for the setgid(2) system call. It is intended - * to provide a limited exposure of the system call, for now. It - * should/will be extended when full functional tests are written for - * setgid(2). - * - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Otherwise, Issue a PASS message. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * - * - *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ - + */ #include <errno.h> #include <string.h> #include <signal.h> + #include "test.h" #include "usctest.h" - -static void setup(); -static void cleanup(); - #include "compat_16.h" +static void setup(void); +static void cleanup(void); + TCID_DEFINE(setgid01); int TST_TOTAL = 1; -int exp_enos[] = { 0, 0 }; +static int exp_enos[] = { 0, 0 }; -GID_T gid; +static gid_t gid; int main(int ac, char **av) { int lc; char *msg; - /*************************************************************** - * parse standard options - ***************************************************************/ if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "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++) { - tst_count = 0; - /* - * Call setgid(2) - */ - TEST(SETGID(gid)); + TEST(SETGID(cleanup, 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 %ld", gid, @@ -176,38 +83,21 @@ int main(int ac, char **av) } - /*************************************************************** - * cleanup and exit - ***************************************************************/ cleanup(); tst_exit(); - tst_exit(); - } -/*************************************************************** - * setup() - performs all ONE TIME setup for this test. - ***************************************************************/ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); TEST_PAUSE; - gid = GETGID(); + gid = getgid(); + GID16_CHECK(gid, setgid, cleanup); } -/*************************************************************** - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - ***************************************************************/ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ TEST_CLEANUP; - } diff --git a/testcases/kernel/syscalls/setgid/setgid02.c b/testcases/kernel/syscalls/setgid/setgid02.c index f3894b1..352d1cd 100644 --- a/testcases/kernel/syscalls/setgid/setgid02.c +++ b/testcases/kernel/syscalls/setgid/setgid02.c @@ -1,85 +1,63 @@ /* + * Copyright (c) International Business Machines Corp., 2001 + * Ported by Wayne Boyer * - * 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 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. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* - * NAME - * setgid02.c - * - * DESCRIPTION - * Testcase to ensure that the setgid() system call sets errno to EPERM + * Testcase to ensure that the setgid() system call sets errno to EPERM * * ALGORITHM * Call setgid() to set the gid to that of root. Run this test as * ltpuser1, and expect to get EPERM - * - * USAGE: <for command-line> - * setgid02 [-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 - * Must be run as a nonroot user */ #include <pwd.h> #include <errno.h> + #include "test.h" #include "usctest.h" +#include "compat_16.h" TCID_DEFINE(setgid02); int TST_TOTAL = 1; -char root[] = "root"; -char nobody_uid[] = "nobody"; -char nobody_gid[] = "nobody"; -struct passwd *ltpuser; +static char root[] = "root"; +static char nobody_uid[] = "nobody"; +static char nobody_gid[] = "nobody"; +static struct passwd *ltpuser; static void setup(void); static void cleanup(void); -#include "compat_16.h" - -int exp_enos[] = { EPERM, 0 }; +static int exp_enos[] = { EPERM, 0 }; int main(int ac, char **av) { struct passwd *getpwnam(), *rootpwent; - int lc; - char *msg; /* message returned by parse_opts */ + char *msg; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } setup(); TEST_EXP_ENOS(exp_enos); for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset tst_count in case we are looping */ tst_count = 0; if ((rootpwent = getpwnam(root)) == NULL) { @@ -87,14 +65,9 @@ int main(int ac, char **av) "%s", root); } - if (!GID_SIZE_CHECK(rootpwent->pw_gid)) { - tst_brkm(TBROK, - cleanup, - "gid for `%s' is too large for testing setgid16", - root); - } + GID16_CHECK(rootpwent->pw_gid, setgid, cleanup); - TEST(SETGID(rootpwent->pw_gid)); + TEST(SETGID(cleanup, rootpwent->pw_gid)); if (TEST_RETURN != -1) { tst_resm(TFAIL, "call succeeded unexpectedly"); @@ -110,29 +83,20 @@ int main(int ac, char **av) tst_resm(TPASS, "setgid returned EPERM"); } } + cleanup(); tst_exit(); - tst_exit(); - } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { -/* Switch to nobody user for correct error code collection */ - if (geteuid() != 0) { - tst_brkm(TBROK, NULL, "Test must be run as root"); - } - ltpuser = getpwnam(nobody_uid); + tst_require_root(NULL); - if (!GID_SIZE_CHECK(ltpuser->pw_gid)) { - tst_brkm(TBROK, - cleanup, - "gid for `%s' is too large for testing setgid16", - nobody_gid); - } + /* Switch to nobody user for correct error code collection */ + ltpuser = getpwnam(nobody_uid); + if (ltpuser == NULL) + tst_brkm(TBROK, cleanup, "getpwnam failed for user id %s", + nobody_uid); if (setgid(ltpuser->pw_gid) == -1) { tst_resm(TINFO, "setgid failed to " @@ -151,16 +115,7 @@ void setup() TEST_PAUSE; } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - ... [truncated message content] |
From: Cyril H. <su...@li...> - 2013-09-10 12:51:22
|
The branch, master, has been updated via 372fbd2416fd02b205690443f93e609c462b409e (commit) via f6c0e345365811dd667646548ecda722f899993e (commit) via 473b8cf5d6a40a46fcb2e082437ac7fdc5a3db96 (commit) via 7d7904eec92d4a7493897c1b87799a494cefcb96 (commit) via ed49c1a0a485d278a469a3236351b3af5405a24c (commit) via 189c4419610af11c31685b4ed1ffda154cbf4f4b (commit) from 0f3ac8c323de141fb2d3fb4339819ee117e58124 (commit) - Log ----------------------------------------------------------------- commit 372fbd2416fd02b205690443f93e609c462b409e Author: Alexey Kodanev <ale...@or...> Date: Tue Sep 10 13:05:01 2013 +0400 device-drivers: rtc: enable the test to build and run Signed-off-by: Alexey Kodanev <ale...@or...> Signed-off-by: Cyril Hrubis <ch...@su...> commit f6c0e345365811dd667646548ecda722f899993e Author: Cyril Hrubis <ch...@su...> Date: Tue Sep 10 14:41:17 2013 +0200 device-drivers: rename rtc-test to rtc01 So that the binary name matches the test name (TCID). Signed-off-by: Cyril Hrubis <ch...@su...> commit 473b8cf5d6a40a46fcb2e082437ac7fdc5a3db96 Author: Alexey Kodanev <ale...@or...> Date: Mon Sep 9 16:23:01 2013 +0400 device-drivers: rtc: minor updates Makefile updated. Added .gitignore file. Added root check and rtc device check. Signed-off-by: Alexey Kodanev <ale...@or...> commit 7d7904eec92d4a7493897c1b87799a494cefcb96 Author: Alexey Kodanev <ale...@or...> Date: Tue Sep 10 12:14:50 2013 +0400 device-drivers: include device-drivers directory to the LTP build Signed-off-by: Alexey Kodanev <ale...@or...> commit ed49c1a0a485d278a469a3236351b3af5405a24c Author: Alexey Kodanev <ale...@or...> Date: Tue Sep 10 12:14:49 2013 +0400 device-drivers: add makefile to build drivers Signed-off-by: Alexey Kodanev <ale...@or...> commit 189c4419610af11c31685b4ed1ffda154cbf4f4b Author: DAN LI <li...@cn...> Date: Tue Sep 10 10:53:34 2013 +0800 runltp: bigger the supplied block device To make a xfs filesystem, we need the device gets at least 4096 blocks. Signed-off-by: DAN LI <li...@cn...> Acked-by: Cyril Hrubis <ch...@su...> ----------------------------------------------------------------------- Summary of changes: runltp | 4 +- runtest/kernel_misc | 1 + testcases/kernel/Makefile | 1 + .../fw_load_user => device-drivers}/Makefile | 9 +++-- testcases/kernel/device-drivers/rtc/.gitignore | 1 + testcases/kernel/device-drivers/rtc/Makefile | 39 ++++++++------------ .../device-drivers/rtc/{rtc-test.c => rtc01.c} | 32 ++++++++++++++--- 7 files changed, 53 insertions(+), 34 deletions(-) copy testcases/kernel/{firmware/fw_load_user => device-drivers}/Makefile (84%) create mode 100644 testcases/kernel/device-drivers/rtc/.gitignore rename testcases/kernel/device-drivers/rtc/{rtc-test.c => rtc01.c} (89%) diff --git a/runltp b/runltp index e86f5c7..63c625f 100755 --- a/runltp +++ b/runltp @@ -955,8 +955,8 @@ main() create_block() { - #create a block device with ext4 filesystem. - dd if=/dev/zero of=${TMP}/test.img bs=1kB count=10240 + #create a block device + dd if=/dev/zero of=${TMP}/test.img bs=1kB count=20480 if [ $? -ne 0 ]; then echo "Failed to create loopback device image, please check disk space and re-run" return 1 diff --git a/runtest/kernel_misc b/runtest/kernel_misc index 73e21a7..29071b3 100644 --- a/runtest/kernel_misc +++ b/runtest/kernel_misc @@ -1,2 +1,3 @@ kmsg01 kmsg01 fw_load fw_load +rtc01 rtc01 diff --git a/testcases/kernel/Makefile b/testcases/kernel/Makefile index 811fcca..fa6a191 100644 --- a/testcases/kernel/Makefile +++ b/testcases/kernel/Makefile @@ -38,6 +38,7 @@ ifneq ($(UCLINUX),1) SUBDIRS += connectors \ containers \ controllers \ + device-drivers \ firmware \ fs \ hotplug \ diff --git a/testcases/kernel/firmware/fw_load_user/Makefile b/testcases/kernel/device-drivers/Makefile similarity index 84% copy from testcases/kernel/firmware/fw_load_user/Makefile copy to testcases/kernel/device-drivers/Makefile index effd5da..62005c2 100644 --- a/testcases/kernel/firmware/fw_load_user/Makefile +++ b/testcases/kernel/device-drivers/Makefile @@ -14,7 +14,10 @@ # along with this program; if not, write the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -top_srcdir ?= ../../../.. +top_srcdir ?= ../../.. -include $(top_srcdir)/include/mk/testcases.mk -include $(top_srcdir)/include/mk/generic_leaf_target.mk +include $(top_srcdir)/include/mk/env_pre.mk + +SUBDIRS := rtc \ + +include $(top_srcdir)/include/mk/generic_trunk_target.mk diff --git a/testcases/kernel/device-drivers/rtc/.gitignore b/testcases/kernel/device-drivers/rtc/.gitignore new file mode 100644 index 0000000..727656a --- /dev/null +++ b/testcases/kernel/device-drivers/rtc/.gitignore @@ -0,0 +1 @@ +/rtc-test diff --git a/testcases/kernel/device-drivers/rtc/Makefile b/testcases/kernel/device-drivers/rtc/Makefile index 0eefcb0..effd5da 100644 --- a/testcases/kernel/device-drivers/rtc/Makefile +++ b/testcases/kernel/device-drivers/rtc/Makefile @@ -1,29 +1,20 @@ +# Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. # -# Copyright (c) Larsen & Toubro Infotech Ltd., 2010 +# 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 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 would 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. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# - -CFLAGS = -O2 -Wall -I ../../../../include/ -LIBS = -L ../../../../lib/ -lltp -SRC = rtc-test.c - +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -all: $(SRC) - $(CC) $(SRC) $(CFLAGS) $(LIBS) -o rtc-test +top_srcdir ?= ../../../.. -clean: - rm -f rtc-test +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/device-drivers/rtc/rtc-test.c b/testcases/kernel/device-drivers/rtc/rtc01.c similarity index 89% rename from testcases/kernel/device-drivers/rtc/rtc-test.c rename to testcases/kernel/device-drivers/rtc/rtc01.c index 28c1113..aa931f5 100644 --- a/testcases/kernel/device-drivers/rtc/rtc-test.c +++ b/testcases/kernel/device-drivers/rtc/rtc01.c @@ -3,6 +3,7 @@ * Tests for the Real Time Clock driver. * * Copyright (c) Larsen & Toubro Infotech Ltd., 2010 + * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. * * Author : Silesh C V <Sil...@ln...> * @@ -21,7 +22,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "test.h" + #include <sys/ioctl.h> #include <stdio.h> #include <stdlib.h> @@ -31,10 +32,26 @@ #include <errno.h> #include <time.h> +#include "test.h" +#include "usctest.h" + int rtc_fd = -1; char *TCID = "rtc01"; int TST_TOTAL = 3; +static char *rtc_dev = "/dev/rtc"; +static int dflag; +static const option_t options[] = { + {"d:", &dflag, &rtc_dev}, + {NULL, NULL, NULL} +}; + +static void help(void) +{ + printf(" -d x rtc device node, default is %s\n", + rtc_dev); +} + /* Read and Alarm Tests : Read test reads the Date/time from RTC * while Alarm test, sets the alarm to 5 seconds in future and * waits for it to ring.The ioctls tested in these tests are @@ -192,12 +209,17 @@ void update_interrupts_test(void) tst_resm(TPASS, "RTC UPDATE INTERRUPTS TEST Passed"); } -int main(int argc, char **argv) +int main(int argc, char *argv[]) { - char *rtc_dev = "/dev/rtc"; + char *msg; + msg = parse_opts(argc, argv, options, help); + if (msg != NULL) + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); + + tst_require_root(NULL); - if (argc == 2) - rtc_dev = argv[1]; + if (access(rtc_dev, F_OK) == -1) + tst_brkm(TCONF, NULL, "couldn't find rtc device '%s'", rtc_dev); rtc_fd = open(rtc_dev, O_RDONLY); hooks/post-receive -- ltp |