changeset 8787:e6cc4a44ff1a

Tests for module 'sleep'.
author Bruno Haible <bruno@clisp.org>
date Tue, 01 May 2007 22:17:02 +0000
parents b7c6961fb530
children a6de3a541ad4
files modules/sleep-tests tests/test-sleep.c
diffstat 2 files changed, 58 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/modules/sleep-tests
@@ -0,0 +1,11 @@
+Files:
+tests/test-sleep.c
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-sleep
+check_PROGRAMS += test-sleep
+
new file mode 100644
--- /dev/null
+++ b/tests/test-sleep.c
@@ -0,0 +1,47 @@
+/* Test of sleep() function.
+   Copyright (C) 2007 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+  do									     \
+    {									     \
+      if (!(expr))							     \
+        {								     \
+          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+          abort ();							     \
+        }								     \
+    }									     \
+  while (0)
+
+int
+main()
+{
+  ASSERT (sleep (1) <= 1);
+
+  ASSERT (sleep (0) == 0);
+
+  return 0;
+}
+