summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.syscall/alarm.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/systemtap.syscall/alarm.c')
-rwxr-xr-xtestsuite/systemtap.syscall/alarm.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/testsuite/systemtap.syscall/alarm.c b/testsuite/systemtap.syscall/alarm.c
new file mode 100755
index 00000000..bae92253
--- /dev/null
+++ b/testsuite/systemtap.syscall/alarm.c
@@ -0,0 +1,44 @@
+/* COVERAGE: alarm nanosleep pause */
+#include <sys/types.h>
+#include <unistd.h>
+#include <time.h>
+#include <string.h>
+#include <signal.h>
+
+static void
+sigrt_act_handler(int signo, siginfo_t *info, void *context)
+{
+}
+
+int main()
+{
+ struct timespec rem, t = {0,789};
+ struct sigaction sigrt_act;
+ memset(&sigrt_act, 0, sizeof(sigrt_act));
+ sigrt_act.sa_handler = (void *)sigrt_act_handler;
+ sigaction(SIGALRM, &sigrt_act, NULL);
+
+ alarm(1);
+ // alarm (1) = 0
+
+ pause();
+ // pause () =
+
+ alarm(0);
+ // alarm (0) = 0
+
+ sleep(1);
+ // nanosleep (\[1.000000000\], XXXX) = 0
+
+ usleep(1234);
+ // nanosleep (\[0.001234000\], 0x[0]+) = 0
+
+ nanosleep(&t, &rem);
+ // nanosleep (\[0.000000789\], XXXX) = 0
+
+ nanosleep(&t, NULL);
+ // nanosleep (\[0.000000789\], 0x[0]+) = 0
+
+ return 0;
+}
+