summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Douglas <william.douglas@intel.com>2012-05-24 14:31:35 -0700
committerWilliam Douglas <william.douglas@intel.com>2012-05-24 14:31:35 -0700
commit60e1a8cff19dd42c736d83b03afb530bee243bd6 (patch)
tree87be48ccb588ca2f867ea57d225d65f47d7cde42
parentb92d5b5b092aec634913ebee3533b435425ec4b7 (diff)
downloadcorewatcher-60e1a8cff19dd42c736d83b03afb530bee243bd6.tar.gz
corewatcher-60e1a8cff19dd42c736d83b03afb530bee243bd6.tar.bz2
corewatcher-60e1a8cff19dd42c736d83b03afb530bee243bd6.zip
add test that generates a core for corewatcher
Signed-off-by: William Douglas <william.douglas@intel.com>
-rw-r--r--tests/bad-write.c11
-rwxr-xr-xtests/run-test.sh12
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/bad-write.c b/tests/bad-write.c
new file mode 100644
index 0000000..5f63e80
--- /dev/null
+++ b/tests/bad-write.c
@@ -0,0 +1,11 @@
+#include <unistd.h>
+#include <stdio.h>
+
+int main(void)
+{
+ char *c = NULL;
+
+ c[0] = 'a';
+
+ return 0;
+}
diff --git a/tests/run-test.sh b/tests/run-test.sh
new file mode 100755
index 0000000..781fb81
--- /dev/null
+++ b/tests/run-test.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+exec 2> /dev/null
+ulimit -c unlimited
+
+original_core_pattern=$(cat /proc/sys/kernel/core_pattern)
+
+sudo echo "$PWD/core" | sudo tee /proc/sys/kernel/core_pattern > /dev/null
+
+./bad-write
+
+sudo echo "$original_core_pattern" | sudo tee /proc/sys/kernel/core_pattern > /dev/null