From 60e1a8cff19dd42c736d83b03afb530bee243bd6 Mon Sep 17 00:00:00 2001 From: William Douglas Date: Thu, 24 May 2012 14:31:35 -0700 Subject: [PATCH] add test that generates a core for corewatcher Signed-off-by: William Douglas --- tests/bad-write.c | 11 +++++++++++ tests/run-test.sh | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/bad-write.c create mode 100755 tests/run-test.sh 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 +#include + +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 -- 2.7.4