shithub: scc

Download patch

ref: de505b2650948c2f4ada5368eaf8a019cf1099bc
parent: 45616fa5eb14079439ca632cdff42ed216fdef97
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Sep 1 11:20:06 EDT 2018

[tests/libc] Add tests for assert()

--- /dev/null
+++ b/tests/libc/execute/0002-assert.c
@@ -1,0 +1,26 @@
+
+#include <assert.h>
+#include <signal.h>
+
+void
+handler(void)
+{
+	_Exit(0);
+}
+
+int
+main()
+{
+	int i;
+	char c;
+
+	signal(SIGABRT, handler);
+
+	printf("First assert\n");
+	assert(sizeof(i) >= sizeof(c));
+
+	printf("Second assert, that must fail\n");
+	assert(sizeof(i) < sizeof(c));
+
+	return 1;
+}
--- /dev/null
+++ b/tests/libc/execute/0002-assert.txt
@@ -1,0 +1,2 @@
+First assert
+Second assert, that must fail
--- /dev/null
+++ b/tests/libc/execute/0003-assert.c
@@ -1,0 +1,20 @@
+#include <assert.h>
+#include <signal.h>
+
+int
+main()
+{
+	int i;
+	char c;
+
+	printf("First assert\n");
+	assert(sizeof(i) >= sizeof(c));
+
+#define NDEBUG
+#include <assert.h>
+
+	printf("Second assert, that must fail\n");
+	assert(sizeof(i) < sizeof(c));
+
+	return 0;
+}
--- /dev/null
+++ b/tests/libc/execute/0003-assert.txt
@@ -1,0 +1,2 @@
+First assert
+Second assert, that must fail
--- a/tests/libc/execute/libc-tests.lst
+++ b/tests/libc/execute/libc-tests.lst
@@ -1,1 +1,3 @@
 0001-abort
+0002-assert
+0003-assert