Hi John, On Mon, 2009-04-13 at 17:57 +0530, Manas K Nayak wrote: > Hi John, > > >cacheflush man page states that cacheflush() will set EINVAL if cache > >parameter is not one of ICACHE, DCACHE, or BCACHE. > >In order to confirm this behavior, I have executed the below listed > >program (cacheflush_check.c) in Toshiba RBTX4937 board (MIPS) with > >2.6.29.1 kernel. > > I picked up this test program written by you and ported the same to LTP > under GPL. It would be great if you do not have any objection in > contributing this test to LTP. The below patch does exactly that.
Do you have any objection in contributing this test to LTP ? Regards-- Subrata > > Original-Author: Maxin John <[email protected]>, > Ported-To-LTP-By: Manas K Nayak <[email protected]>, > --- > > --- > ltp-full-20090331.orig/testcases/kernel/syscalls/cacheflush/cacheflush01.c > 1970-01-01 05:30:00.000000000 +0530 > +++ ltp-full-20090331/testcases/kernel/syscalls/cacheflush/cacheflush01.c > 2009-04-13 17:33:00.000000000 +0530 > @@ -0,0 +1,192 @@ > +/******************************************************************************/ > +/* Copyright (c) Maxin John <[email protected]>, 2009 > */ > +/* LKML Reference: http://lkml.org/lkml/2009/4/9/203 > */ > +/* This program is free software; you can redistribute it and/or modify > */ > +/* it under the terms of the GNU General Public License as published by > */ > +/* the Free Software Foundation; either version 2 of the License, or > */ > +/* (at your option) any later version. > */ > +/* > */ > +/* This program is distributed in the hope that it will be useful, > */ > +/* but WITHOUT ANY WARRANTY; without even the implied warranty of > */ > +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > */ > +/* the GNU General Public License for more details. > */ > +/* > */ > +/* You should have received a copy of the GNU General Public License > */ > +/* along with this program; if not, write to the Free Software > */ > +/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > */ > +/* > */ > +/******************************************************************************/ > +/******************************************************************************/ > +/* > */ > +/* File: cacheflush01.c > */ > +/* > */ > +/* Description: The cacheflush_check() syscall > */ > +/* Tests EINVAL error of cacheflush system call. > */ > +/* Its expected behaviour is cacheflush() should return -EINVAL */ > +/* when cache parameter is not one of ICACHE, DCACHE, or BCACHE. */ > +/* > */ > +/* Usage: <for command-line> > */ > +/* cacheflush01 [-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. > */ > +/* > */ > +/* Total Tests: 1 > */ > +/* > */ > +/* Test Name: cacheflush01 > */ > +/******************************************************************************/ > + > +#include <sys/syscall.h> > +#include <unistd.h> > +#include <stdio.h> > +#include <stdlib.h> > +#include <errno.h> > + > +#if defined __mips__ > +#include <asm/cachectl.h> > +int cacheflush(char *addr, int nbytes, int cache) > +{ > +B B B B return syscall(__NR_cacheflush, addr, nbytes, cache); > +} > +#endif /* __mips__ */ > + > +#ifndef ICACHE > +#define ICACHE (1<<0) /* flush instruction cache */ > +#endif > +#ifndef DCACHE > +#define DCACHE (1<<1) /* writeback and flush data cache */ > +#endif > +#ifndef BCACHE > +#define BCACHE (ICACHE|DCACHE) /* flush both caches */ > +#endif > + > +/* Harness Specific Incnude Files. */ > +#include "test.h" > +#include "usctest.h" > +#include "linux_syscall_numbers.h" > + > +/* Extern Global Variables */ > +extern int Tst_count; /* counter for tst_xxx routines. */ > +extern char *TESTDIR; /* temporary dir created by tst_tmpdir() */ > + > +/* Global Variables */ > +char *TCID = "cacheflush01"; /* Test program identifier.*/ > +int testno; > +int TST_TOTAL = 1; /* total number of tests in this file. > */ > + > +#if defined __mips__ > +/* Extern Global Functions */ > +/******************************************************************************/ > +/* > */ > +/* Function: cleanup > */ > +/* > */ > +/* Description: Performs all one time clean up for this test on successful > */ > +/* completion, premature exit or failure. Closes all > temporary */ > +/* files, removes all temporary directories exits the test with > */ > +/* appropriate return code by calling tst_exit() function. > */ > +/* > */ > +/* Input: None. > */ > +/* > */ > +/* Output: None. > */ > +/* > */ > +/* Return: On failure - Exits calling tst_exit(). Non '0' return code. > */ > +/* On success - Exits calling tst_exit(). With '0' return code. > */ > +/* > */ > +/******************************************************************************/ > +extern void cleanup() { > + /* Remove tmp dir and all files in it */ > + TEST_CLEANUP; > + tst_rmdir(); > + > + /* Exit with appropriate return code. */ > + tst_exit(); > +} > + > +/* Local Functions */ > +/******************************************************************************/ > +/* > */ > +/* Function: setup > */ > +/* > */ > +/* Description: Performs all one time setup for this test. This function is > */ > +/* typically used to capture signals, create temporary dirs > */ > +/* and temporary files that may be used in the course of this > */ > +/* test. > */ > +/* > */ > +/* Input: None. > */ > +/* > */ > +/* Output: None. > */ > +/* > */ > +/* Return: On failure - Exits by calling cleanup(). > */ > +/* On success - returns 0. > */ > +/* > */ > +/******************************************************************************/ > +void setup() { > + /* Capture signals if any */ > + /* Create temporary directories */ > + TEST_PAUSE; > + tst_tmpdir(); > +} > + > +int main(int ac, char **av) { > + > + /* cacheflush man page states that cacheflush() is only > applicable to MIPS architecture */ > + char *addr = NULL; > + int lc; /* loop counter */ > + char *msg; /* message returned from parse_opts */ > + > + /* parse standard options */ > + if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char > *)NULL){ > + tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg); > + tst_exit(); > + } > + > + setup(); > + > + /* Check looping state if -i option given */ > + for (lc = 0; TEST_LOOPING(lc); ++lc) { > + Tst_count = 0; > + for (testno = 0; testno < TST_TOTAL; ++testno) { > + /* Create some user address range */ > + addr = malloc(getpagesize()); > + if (addr == NULL) { > + tst_resm(TFAIL, "%s, Malloc error errno = %d : > %s",TCID, TEST_ERRNO, strerror(TEST_ERRNO)); > + cleanup(); > + tst_exit(); > + } > + > + /* Invokes cacheflush() with proper parameters */ > + TEST(cacheflush(addr, getpagesize(), ICACHE)); > + TEST(cacheflush(addr, getpagesize(), DCACHE)); > + TEST(cacheflush(addr, getpagesize(), BCACHE)); > + > + /* Tests whether cacheflush() returns -EINVAL */ > + TEST(cacheflush(addr, getpagesize(), 0)); > + if(TEST_RETURN < 0){ > + if (TEST_ERRNO == EINVAL) { > + tst_resm(TPASS, "%s PASS -with expected errno = > %d : %s\n", TCID, TEST_ERRNO, strerror(TEST_ERRNO)); > + cleanup(); > + tst_exit(); > + } else { > + tst_resm(TFAIL, "%s FAIL -with unexpected errno > = %d : %s\n", TCID, TEST_ERRNO, strerror(TEST_ERRNO)); > + cleanup(); > + tst_exit(); > + } > + } > + tst_resm(TFAIL, "%s FAIL -with unexpected errno = %d : > %s\n", TCID, TEST_ERRNO, strerror(TEST_ERRNO)); > + cleanup(); > + } > + > + } > + tst_exit(); > +} > + > +#else > +int main(int ac, char **av) { > + > + tst_resm(TCONF, "is not available for this architecture"); > + tst_exit(); > +} > +#endif > --- ltp-full-20090331.orig/testcases/kernel/syscalls/cacheflush/Makefile > 1970-01-01 05:30:00.000000000 +0530 > +++ ltp-full-20090331/testcases/kernel/syscalls/cacheflush/Makefile > 2009-04-13 17:16:11.000000000 +0530 > @@ -0,0 +1,31 @@ > +# > +# Copyright (c) International Business Machines Corp., 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 St, Fifth Floor, Boston, MA 02110-1301 USA > +# > + > +CFLAGS += -I../../../../include -Wall > +LDLIBS += -L../../../../lib -lltp > + > +SRCS = $(wildcard *.c) > +TARGETS = $(patsubst %.c,%,$(SRCS)) > + > +all: $(TARGETS) > + > +install: > + @set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done > + > +clean: > + rm -f $(TARGETS) > --- ltp-full-20090331.orig/runtest/syscalls 2009-04-13 17:43:04.000000000 > +0530 > +++ ltp-full-20090331/runtest/syscalls 2009-04-13 17:35:46.000000000 > +0530 > @@ -36,6 +36,8 @@ capget02 capget02 > capset01 capset01 > capset02 capset02 > > +cacheflush01 cacheflush01 > + > chdir01 chdir01 > chdir01A symlink01 -T chdir01 > chdir02 chdir02 > > --- > Regards-- > Manas > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > High Quality Requirements in a Collaborative Environment. > Download a free trial of Rational Requirements Composer Now! > http://p.sf.net/sfu/www-ibm-com > _______________________________________________ Ltp-list mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/ltp-list ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
