From 01c165cd1b2ac601d5ae73d3cb5e82ccdd94ac94 Mon Sep 17 00:00:00 2001 From: Le Chi Thu Date: Tue, 3 Apr 2012 01:23:00 +0200 Subject: Initial commit --- kernel/testcases/dma/user-space/Makefile | 26 ++++ kernel/testcases/dma/user-space/dma.c | 156 ++++++++++++++++++++++++ kernel/testcases/dma/user-space/dma_test_all.sh | 81 ++++++++++++ 3 files changed, 263 insertions(+) create mode 100644 kernel/testcases/dma/user-space/Makefile create mode 100644 kernel/testcases/dma/user-space/dma.c create mode 100755 kernel/testcases/dma/user-space/dma_test_all.sh (limited to 'kernel/testcases/dma/user-space') diff --git a/kernel/testcases/dma/user-space/Makefile b/kernel/testcases/dma/user-space/Makefile new file mode 100644 index 0000000..e950b1f --- /dev/null +++ b/kernel/testcases/dma/user-space/Makefile @@ -0,0 +1,26 @@ +ifeq ($(KERNELRELEASE),) +LTP_DIR = $(abspath ../../../../) +LTP_FRAMEWORK = $(LTP_DIR)/ltp_framework + +SCRIPTS=$(wildcard *.sh) + +CFLAGS+= -I$(LTP_FRAMEWORK)/include -I$(abspath ./include) +LOADLIBES+= -L$(LTP_FRAMEWORK)/lib -lltp + +TARGETS=dma +OBJS=dma.o + +all: $(TARGETS) + +$(TARGETS): $(TARGETS) $(OBJS) + +install: + @for i in $(TARGETS); do if [ -f $(DESTDIR)/opt/ltp/testcases/bin/$$i ]; then rm $(DESTDIR)/opt/ltp/testcases/bin/$$i; fi ; done + @for i in $(TARGETS); do install -D $$i $(DESTDIR)/opt/ltp/testcases/bin/$$i ; done + @for i in $(SCRIPTS); do if [ -f $(DESTDIR)/opt/ltp/testcases/bin/$$i ]; then rm $(DESTDIR)/opt/ltp/testcases/bin/$$i; fi ; done + @for i in $(SCRIPTS); do install -D $$i $(DESTDIR)/opt/ltp/testcases/bin/$$i ; done + +clean: + rm -f $(TARGETS) + rm -f $(OBJS) +endif diff --git a/kernel/testcases/dma/user-space/dma.c b/kernel/testcases/dma/user-space/dma.c new file mode 100644 index 0000000..f3dd062 --- /dev/null +++ b/kernel/testcases/dma/user-space/dma.c @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2010 ST-Ericsson + * License terms: GNU General Public License (GPL) version 2 + * + * Author: 2010, Martin Persson , + * Jonas Aaberg + */ + +#include "test.h" +#include "usctest.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + + + +/* 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 = "dma"; + +int test_cases[] = { + 22, 23, 24, 25, 1, 2, 3, 4, 6, 7, 8, + 21, 15, 16, 17, 18, 19, 20, 21, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, + + /* run long tests near the end */ + 26, 7, 32, 33, 5, 34, 27, 28, 29, + + /* + * The following fail: + * + * This due to hardware error V1, should be fixed in V2: + * 30, 31, 35, 51 + * + * These fail due to unknown reason: + * 9 + */ +}; + +/* total number of tests in this file. */ +int TST_TOTAL = sizeof(test_cases); + +static int dma_test(int id) +{ + int fd = 0, size, err = 0; + char fname[256], buff[256], answer[256]; + + sprintf(fname, "/sys/kernel/debug/ste_dma40_test/test_%d", id); + + fd = open(fname, O_RDONLY); + + if (fd < 0) { + err = -1; + goto _exit; + } + memset(buff, 0, 256); + size = read(fd, buff, 255); + if (size <= 0) { + err = -2; + goto _exit; + } + + sprintf(answer, "Finished test %d: OK\n", id); + if (size != strlen(answer)) { + printf("DMA testcase %d failed\n", id); + err = -3; + goto _exit; + } + + if (strncmp(buff, answer, strlen(answer))) { + printf("DMA testcase %d failed\n", id); + err = -4; + } + +_exit: + if (fd > 0) + close(fd); + + return err; +} + +static int n_opt; +static char *n_copt; +static int testnum; + +static option_t options[] = { + { "n:", &n_opt, &n_copt }, + { }, +}; + +int main(int argc, char **argv) +{ + + int lc; /* loop counter */ + char *msg; /* message returned from parse_opts */ + + /*************************************************************** + * parse standard options + ***************************************************************/ + if ((msg = parse_opts(argc, argv, options, NULL)) != (char *) NULL) { + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); + tst_exit(); + } + + if (n_opt) { + testnum = atoi(n_copt); + TST_TOTAL = 1; + } + + system("modprobe stedma40_test"); + + for (lc = 0; TEST_LOOPING(lc); lc++) { + + /*************************************************************** + * only perform functional verification if flag set (-f not given) + ***************************************************************/ + if (STD_FUNCTIONAL_TEST) { + + for (Tst_count = 0; Tst_count < TST_TOTAL;) { + int num; + + num = TST_TOTAL == 1 ? + testnum : test_cases[Tst_count]; + + TEST(dma_test(num)); + + if (TEST_RETURN == 0) + tst_resm(TPASS, "Functional test %d OK\n", num); + else + tst_resm(TFAIL, "Return value: %d. TCID: %s (%d) File: %s Line: %d. errno=%d : %s \n", + TEST_RETURN, TCID, num, __FILE__, __LINE__, + TEST_ERRNO, strerror(TEST_ERRNO)); + + } + } + } + + system("modprobe -r stedma40_test"); + + tst_exit(); + return 0; +} diff --git a/kernel/testcases/dma/user-space/dma_test_all.sh b/kernel/testcases/dma/user-space/dma_test_all.sh new file mode 100755 index 0000000..3a3aa94 --- /dev/null +++ b/kernel/testcases/dma/user-space/dma_test_all.sh @@ -0,0 +1,81 @@ +#/* +# * Copyright (C) ST-Ericsson SA 2010 +# * License Terms: GNU General Public License, version 2 +# */ + +# Runs all test for DMA +TEST_MODULE_NAME=stedma40_test +TEST_DIR=/sys/kernel/debug/ste_dma40_test +TEST_TMP_FILE=/.dma_run_test.sh + +echo "Loading test module $TEST_MODULE" +modprobe $TEST_MODULE_NAME +cd $TEST_DIR + +cat test_22 +cat test_23 +cat test_24 +cat test_25 + +cat test_1 +cat test_2 +cat test_3 +cat test_4 +cat test_6 +cat test_7 +cat test_8 + +# Testing dma using MMC +cat test_10 > $TEST_TMP_FILE +sh $TEST_TMP_FILE +cat test_11 > $TEST_TMP_FILE +sh $TEST_TMP_FILE +cat test_12 > $TEST_TMP_FILE +sh $TEST_TMP_FILE +cat test_13 > $TEST_TMP_FILE +sh $TEST_TMP_FILE + +# Endless test case, skip it here +# cat test_14 + +cat test_21 +cat test_15 +cat test_16 +cat test_17 +cat test_18 +cat test_19 +cat test_20 +cat test_21 +cat test_55 +cat test_56 +cat test_57 +cat test_58 +cat test_59 +cat test_60 +cat test_61 +cat test_62 +cat test_63 +cat test_64 + +cat test_26 +# run long tests near the end +cat test_7 +cat test_32 +cat test_33 +cat test_5 +cat test_34 +cat test_27 +cat test_28 +cat test_29 + +# The following fails: +# This due to hardware error V1, should be fixed in V2. +# cat test_30 +# cat test_31 +# cat test_35 +# cat test_51 +# These fail due to unknown reason. +# cat test_9 +# + +rmmod $TEST_MODULE_NAME -- cgit v1.2.3