diff options
author | David Smith <dsmith@redhat.com> | 2010-03-24 10:57:01 -0500 |
---|---|---|
committer | David Smith <dsmith@redhat.com> | 2010-03-24 10:57:01 -0500 |
commit | 6c62bc429ffee4fc1baa798c6b800d98e5698c00 (patch) | |
tree | 8005db88222ba117d65cfe4c59999ce53ccec8cb /testsuite | |
parent | 8689c93ef40caf621524ac4513a1eae143843c05 (diff) | |
download | systemtap-steved-6c62bc429ffee4fc1baa798c6b800d98e5698c00.tar.gz systemtap-steved-6c62bc429ffee4fc1baa798c6b800d98e5698c00.tar.xz systemtap-steved-6c62bc429ffee4fc1baa798c6b800d98e5698c00.zip |
Improved atomic.exp testcase by removing the need for an external module.
* testsuite/systemtap.base/atomic.exp: Removed the need for the external
module by putting the atomic_long_t inside the stap module.
* testsuite/systemtap.base/atomic_module.c: Removed.
* testsuite/systemtap.base/atomic_module.makefile: Ditto.
* testsuite/lib/stap_run_error.exp (stap_run_error): Better error handling.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/lib/stap_run_error.exp | 5 | ||||
-rw-r--r-- | testsuite/systemtap.base/atomic.exp | 76 | ||||
-rw-r--r-- | testsuite/systemtap.base/atomic_module.c | 50 | ||||
-rw-r--r-- | testsuite/systemtap.base/atomic_module.makefile | 13 |
4 files changed, 26 insertions, 118 deletions
diff --git a/testsuite/lib/stap_run_error.exp b/testsuite/lib/stap_run_error.exp index bf894984..84068265 100644 --- a/testsuite/lib/stap_run_error.exp +++ b/testsuite/lib/stap_run_error.exp @@ -50,6 +50,11 @@ proc stap_run_error { TEST_NAME EXPECT_ERROR ERROR_STRING OUTPUT_CHECK_STRING ar fail "$TEST_NAME unexpected error" } } + timeout { + fail "$TEST_NAME shutdown (timeout)" + exec kill -INT -[exp_pid] + } + eof { fail "$TEST_NAME shutdown (eof)" } } } -re "semantic error:" { fail "$TEST_NAME compilation" } diff --git a/testsuite/systemtap.base/atomic.exp b/testsuite/systemtap.base/atomic.exp index 4b4fa58d..ef1647e0 100644 --- a/testsuite/systemtap.base/atomic.exp +++ b/testsuite/systemtap.base/atomic.exp @@ -31,63 +31,31 @@ set test "atomic3" set script [format $script_template "3"] stap_run_error $test 1 $error "" -e $script - -set build_dir "" - -proc cleanup_module {} { - global build_dir - as_root [list /sbin/rmmod atomic_module] - catch { exec rm -rf $build_dir } -} - -proc build_and_install_module {} { - global build_dir - global srcdir subdir - - # Create the build directory and populate it - if {[catch {exec mktemp -d staptestXXXXXX} build_dir]} { - verbose -log "Failed to create temporary directory: $build_dir" - return 0 - } - exec cp $srcdir/$subdir/atomic_module.c $build_dir/ - exec cp -p $srcdir/$subdir/atomic_module.makefile $build_dir/Makefile - - # Build the module - if {[catch {exec make -C $build_dir clean} res]} { - verbose -log "$res" - return 0 - } - catch {exec make -C $build_dir} res - if {![file exists $build_dir/atomic_module.ko]} { - verbose -log "$res" - return 0 - } - - # Install the module - set res [as_root [list /sbin/insmod $build_dir/atomic_module.ko]] - if {$res != 0} { - return 0 - } - - return 1 -} - -set test "atomic_module_build" -if {[build_and_install_module] == 0} { - verbose -log "BUILD FAILED" - fail "$test - could not build/install module" - cleanup_module - return -} else { - pass $test -} +# Since we want to fail semi-gracefully (no compile errors), if we +# don't have atomic_long_t support on this kernel (no +# ATOMIC_LONG_INIT) the testcase will compile, but fail. set script_module_template { + %%{ + #include <asm/atomic.h> + #ifdef ATOMIC_LONG_INIT + struct { + ulong barrier1; + atomic_long_t a; + ulong barrier2; + } stp_atomic_struct = { ULONG_MAX, ATOMIC_LONG_INIT(5), ULONG_MAX }; + #else + struct { + ulong barrier1; + long a; + ulong barrier2; + } stp_atomic_struct = { ULONG_MAX, 5, ULONG_MAX }; + #endif + %%} + function get_atomic_addr:long() %%{ - extern atomic_long_t *stp_get_atomic_long_addr(void); - atomic_long_t *a = stp_get_atomic_long_addr(); - THIS->__retvalue = (long)a; + THIS->__retvalue = (long)&stp_atomic_struct.a; %%} probe begin { @@ -111,5 +79,3 @@ stap_run_error $test 0 $error "5\r\n" -ge $script #set test "atomic5" #set script [format $script_module_template "3"] #stap_run_error $test 1 $error "" -ge $script - -cleanup_module diff --git a/testsuite/systemtap.base/atomic_module.c b/testsuite/systemtap.base/atomic_module.c deleted file mode 100644 index 5b4e395e..00000000 --- a/testsuite/systemtap.base/atomic_module.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- linux-c -*- - * Systemtap Atomic Test Module - * Copyright (C) 2010 Red Hat Inc. - * - * This file is part of systemtap, and is free software. You can - * redistribute it and/or modify it under the terms of the GNU General - * Public License (GPL); either version 2, or (at your option) any - * later version. - */ - -#include <linux/kernel.h> -#include <linux/module.h> -#include <asm/atomic.h> - -/* The purpose of this module is to provide a bunch of functions that */ -/* do nothing important, and then call them in different contexts. */ -/* We use a /proc file to trigger function calls from user context. */ -/* Then systemtap scripts set probes on the functions and run tests */ -/* to see if the expected output is received. This is better than using */ -/* the kernel because kernel internals frequently change. */ - - -/************ Below are the functions to create this module ************/ - -struct { - ulong barrier1; - atomic_long_t a; - ulong barrier2; -} stp_atomic_struct; - -atomic_long_t *stp_get_atomic_long_addr(void) -{ - return(&stp_atomic_struct.a); -} -EXPORT_SYMBOL(stp_get_atomic_long_addr); - -int init_module(void) -{ - stp_atomic_struct.barrier1 = ULONG_MAX; - atomic_long_set(&stp_atomic_struct.a, 5); - stp_atomic_struct.barrier2 = ULONG_MAX; - return 0; -} - -void cleanup_module(void) -{ -} - -MODULE_DESCRIPTION("systemtap atomic test module"); -MODULE_LICENSE("GPL"); diff --git a/testsuite/systemtap.base/atomic_module.makefile b/testsuite/systemtap.base/atomic_module.makefile deleted file mode 100644 index 14d2b8e2..00000000 --- a/testsuite/systemtap.base/atomic_module.makefile +++ /dev/null @@ -1,13 +0,0 @@ -obj-m := atomic_module.o -KDIR := /lib/modules/$(shell uname -r)/build -PWD := $(shell pwd) - -CLEAN_FILES := $(shell echo *.mod.c *.ko *.o .*.cmd *~ *.sgn) -CLEAN_FILES += Module.markers modules.order Module.symvers -CLEAN_DIRS := .tmp_versions - -default: - $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules -clean: - rm -f $(CLEAN_FILES) - rm -rf $(CLEAN_DIRS) |