summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatthew <matthew@openbsd.org>2012-09-06 22:13:44 +0000
committermatthew <matthew@openbsd.org>2012-09-06 22:13:44 +0000
commit476cbaa3fe588cd840e6aaa919cb556b5545c33a (patch)
treeae4e51ab36408d9dbb63ec59d658dac80a88f00a
parentMove the commented out test program in pkcs5_pbkdf2.c into a proper (diff)
downloadwireguard-openbsd-476cbaa3fe588cd840e6aaa919cb556b5545c33a.tar.xz
wireguard-openbsd-476cbaa3fe588cd840e6aaa919cb556b5545c33a.zip
Add a (currently failing) regress test for GNU C++'s init_priority
attribute. See "info --index-search=init_priority gcc" for details on how this feature is supposed to work.
-rw-r--r--regress/lib/csu/init_priority/Makefile6
-rw-r--r--regress/lib/csu/init_priority/init_priority_test.cc45
2 files changed, 51 insertions, 0 deletions
diff --git a/regress/lib/csu/init_priority/Makefile b/regress/lib/csu/init_priority/Makefile
new file mode 100644
index 00000000000..3b7b751c8cc
--- /dev/null
+++ b/regress/lib/csu/init_priority/Makefile
@@ -0,0 +1,6 @@
+# $OpenBSD: Makefile,v 1.1 2012/09/06 22:13:44 matthew Exp $
+
+PROG=init_priority_test
+SRCS=init_priority_test.cc
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/csu/init_priority/init_priority_test.cc b/regress/lib/csu/init_priority/init_priority_test.cc
new file mode 100644
index 00000000000..6855dd93717
--- /dev/null
+++ b/regress/lib/csu/init_priority/init_priority_test.cc
@@ -0,0 +1,45 @@
+/* $OpenBSD: init_priority_test.cc,v 1.1 2012/09/06 22:13:44 matthew Exp $ */
+
+#include <cassert>
+
+namespace {
+const int kNumTests = 10;
+int counter = 0;
+int log[kNumTests];
+
+struct Test {
+ Test(int x);
+};
+
+Test::Test(int x)
+{
+ if (counter < kNumTests)
+ log[counter] = x;
+ counter++;
+}
+
+#define TEST(n) Test test_##n __attribute__((init_priority(n))) (n);
+TEST(12597);
+TEST(20840);
+TEST(31319);
+TEST(17071);
+TEST(47220);
+TEST(40956);
+TEST(28373);
+TEST(8742);
+TEST(14117);
+TEST(6407);
+#undef TEST
+}
+
+int
+main()
+{
+ int i;
+
+ assert(counter == kNumTests);
+ for (i = 1; i < kNumTests; i++)
+ assert(log[i] >= log[i - 1]);
+
+ return (0);
+}