From ebdb5910699fa03a4cac04816951f3c29a10eec0 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 16 Jan 2020 16:32:09 -0800 Subject: [PATCH] Add several tests to test printf of various configurations. wasi-libc builds special versions of printf and other routines optimized for the case where long double and floating-point in general are not needed. Ensure that everything still compiles and runs. --- tests/compile-only/printf-long-double.c | 8 ++++++++ tests/general/printf-long-double-enabled.c | 8 ++++++++ tests/general/printf-long-double-enabled.c.options | 1 + .../general/printf-long-double-enabled.c.stdout.expected | 1 + tests/general/printf-no-float.c | 8 ++++++++ tests/general/printf-no-float.c.stdout.expected | 1 + tests/general/printf-no-long-double.c | 8 ++++++++ tests/general/printf-no-long-double.c.stdout.expected | 1 + 8 files changed, 36 insertions(+) create mode 100644 tests/compile-only/printf-long-double.c create mode 100644 tests/general/printf-long-double-enabled.c create mode 100644 tests/general/printf-long-double-enabled.c.options create mode 100644 tests/general/printf-long-double-enabled.c.stdout.expected create mode 100644 tests/general/printf-no-float.c create mode 100644 tests/general/printf-no-float.c.stdout.expected create mode 100644 tests/general/printf-no-long-double.c create mode 100644 tests/general/printf-no-long-double.c.stdout.expected diff --git a/tests/compile-only/printf-long-double.c b/tests/compile-only/printf-long-double.c new file mode 100644 index 0000000..96fc26a --- /dev/null +++ b/tests/compile-only/printf-long-double.c @@ -0,0 +1,8 @@ +#include + +volatile long double x = 42.0L; + +int main(void) { + printf("the answer is %Lf\n", x); + return 0; +} diff --git a/tests/general/printf-long-double-enabled.c b/tests/general/printf-long-double-enabled.c new file mode 100644 index 0000000..96fc26a --- /dev/null +++ b/tests/general/printf-long-double-enabled.c @@ -0,0 +1,8 @@ +#include + +volatile long double x = 42.0L; + +int main(void) { + printf("the answer is %Lf\n", x); + return 0; +} diff --git a/tests/general/printf-long-double-enabled.c.options b/tests/general/printf-long-double-enabled.c.options new file mode 100644 index 0000000..2b2ec8e --- /dev/null +++ b/tests/general/printf-long-double-enabled.c.options @@ -0,0 +1 @@ +-lc-printscan-long-double diff --git a/tests/general/printf-long-double-enabled.c.stdout.expected b/tests/general/printf-long-double-enabled.c.stdout.expected new file mode 100644 index 0000000..e23e024 --- /dev/null +++ b/tests/general/printf-long-double-enabled.c.stdout.expected @@ -0,0 +1 @@ +the answer is 42.000000 diff --git a/tests/general/printf-no-float.c b/tests/general/printf-no-float.c new file mode 100644 index 0000000..7e8339d --- /dev/null +++ b/tests/general/printf-no-float.c @@ -0,0 +1,8 @@ +#include + +volatile int x = 42; + +int main(void) { + printf("the answer is %d\n", x); + return 0; +} diff --git a/tests/general/printf-no-float.c.stdout.expected b/tests/general/printf-no-float.c.stdout.expected new file mode 100644 index 0000000..5bdef3d --- /dev/null +++ b/tests/general/printf-no-float.c.stdout.expected @@ -0,0 +1 @@ +the answer is 42 diff --git a/tests/general/printf-no-long-double.c b/tests/general/printf-no-long-double.c new file mode 100644 index 0000000..2364ef0 --- /dev/null +++ b/tests/general/printf-no-long-double.c @@ -0,0 +1,8 @@ +#include + +volatile double x = 42.0; + +int main(void) { + printf("the answer is %f\n", x); + return 0; +} diff --git a/tests/general/printf-no-long-double.c.stdout.expected b/tests/general/printf-no-long-double.c.stdout.expected new file mode 100644 index 0000000..e23e024 --- /dev/null +++ b/tests/general/printf-no-long-double.c.stdout.expected @@ -0,0 +1 @@ +the answer is 42.000000