summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiko Catania <>2009-04-08 09:01:38 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-08 09:01:38 -0700
commit1aa5708e437b96e04f31d9c9f167427411ba5510 (patch)
tree6544114759e2d8d5117dfa443188b9a22e7bdc21
parent84011c7599ab8a4463cefda5e8ce8a59987640d8 (diff)
downloadextras-1aa5708e437b96e04f31d9c9f167427411ba5510.tar.gz
AI 145059: (Almost) final set of wrapper around the C headers for stdc++ and their tests.
The only one left is cstring. * bionic/libstdc++/include/cstdlib: * bionic/libstdc++/include/cstdio: * bionic/libstdc++/include/cstdint: * bionic/libstdc++/include/csignal: * bionic/libstdc++/include/csetjmp: Added header file. Checks the bionic headers file were picked up instead of the host ones. Added test for new header files * system/extras/tests/bionic/libstdc++/Android.mk: Added tests for the new header files. EXTRA_CFLAGS: include the bionic header files. BUG=1601432 Automated import of CL 145059
-rw-r--r--tests/bionic/libstdc++/Android.mk8
-rw-r--r--tests/bionic/libstdc++/README.TXT5
-rw-r--r--tests/bionic/libstdc++/test_cassert.cpp5
-rw-r--r--tests/bionic/libstdc++/test_cctype.cpp4
-rw-r--r--tests/bionic/libstdc++/test_climits.cpp6
-rw-r--r--tests/bionic/libstdc++/test_csetjmp.cpp65
-rw-r--r--tests/bionic/libstdc++/test_csignal.cpp68
-rw-r--r--tests/bionic/libstdc++/test_cstddef.cpp6
-rw-r--r--tests/bionic/libstdc++/test_cstdint.cpp45
-rw-r--r--tests/bionic/libstdc++/test_cstdio.cpp166
-rw-r--r--tests/bionic/libstdc++/test_cstdlib.cpp49
-rw-r--r--tests/bionic/libstdc++/test_ctime.cpp4
12 files changed, 428 insertions, 3 deletions
diff --git a/tests/bionic/libstdc++/Android.mk b/tests/bionic/libstdc++/Android.mk
index 4446c87f..2151676b 100644
--- a/tests/bionic/libstdc++/Android.mk
+++ b/tests/bionic/libstdc++/Android.mk
@@ -61,10 +61,18 @@ sources := \
test_cassert.cpp \
test_cctype.cpp \
test_climits.cpp \
+ test_csetjmp.cpp \
+ test_csignal.cpp \
test_cstddef.cpp \
+ test_cstdint.cpp \
+ test_cstdio.cpp \
+ test_cstdlib.cpp \
test_ctime.cpp
+EXTRA_CFLAGS := -I bionic/libstdc++/include
$(call host-test, $(sources))
+
+EXTRA_CFLAGS := -I bionic/libstdc++/include
$(call device-test, $(sources))
endif # BIONIC_TESTS
diff --git a/tests/bionic/libstdc++/README.TXT b/tests/bionic/libstdc++/README.TXT
index 90d40ea9..aa7f8a46 100644
--- a/tests/bionic/libstdc++/README.TXT
+++ b/tests/bionic/libstdc++/README.TXT
@@ -6,9 +6,14 @@ test programs. For example, do:
cd system/extras/tests/bionic/libstdc++
mm BIONIC_TESTS=1
+Preferably, to build and run you can use this:
+
+ runtest_py libstdcpp
+
All test programs should exit with a status code of 0 in case of success, and 1
in case of failure.
The directory layout is currently flat because there is one Bionic test. If you
want to add GNU STDC++ or benchmark tests, look in tests/bionic/libc as an
example how to structure your files.
+
diff --git a/tests/bionic/libstdc++/test_cassert.cpp b/tests/bionic/libstdc++/test_cassert.cpp
index efe73fe5..67c96deb 100644
--- a/tests/bionic/libstdc++/test_cassert.cpp
+++ b/tests/bionic/libstdc++/test_cassert.cpp
@@ -26,8 +26,11 @@
* SUCH DAMAGE.
*/
-// Test that including cassert works.
+
#include <cassert>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CASSERT__
+#error "Wrong header file included!!"
+#endif
namespace {
const int kPassed = 0;
diff --git a/tests/bionic/libstdc++/test_cctype.cpp b/tests/bionic/libstdc++/test_cctype.cpp
index ad6312b6..bedb77fb 100644
--- a/tests/bionic/libstdc++/test_cctype.cpp
+++ b/tests/bionic/libstdc++/test_cctype.cpp
@@ -27,6 +27,10 @@
*/
#include <cctype>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CCTYPE__
+#error "Wrong header file included!!"
+#endif
+
namespace {
const int kPassed = 0;
diff --git a/tests/bionic/libstdc++/test_climits.cpp b/tests/bionic/libstdc++/test_climits.cpp
index 2e5c59ef..f3ce0232 100644
--- a/tests/bionic/libstdc++/test_climits.cpp
+++ b/tests/bionic/libstdc++/test_climits.cpp
@@ -25,7 +25,13 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
+
#include <climits>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CLIMITS__
+#error "Wrong header file included!!"
+#endif
+
namespace {
const int kPassed = 0;
diff --git a/tests/bionic/libstdc++/test_csetjmp.cpp b/tests/bionic/libstdc++/test_csetjmp.cpp
new file mode 100644
index 00000000..9b314909
--- /dev/null
+++ b/tests/bionic/libstdc++/test_csetjmp.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <csetjmp>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSETJMP__
+#error "Wrong header file included!!"
+#endif
+
+
+namespace {
+const int kPassed = 0;
+const int kFailed = 1;
+#define FAIL_UNLESS(f) if (!android::f()) return kFailed;
+} // anonymous namespace
+
+namespace android
+{
+#ifdef longjmp
+#error "longjmp must not be a macro"
+#endif
+
+#ifndef setjmp
+#error "setjmp must be a macro"
+#endif
+
+using std::longjmp;
+
+bool testJmpbuf()
+{
+ volatile std::jmp_buf jmpbuf;
+ return true;
+}
+
+} // namespace android
+
+int main(int argc, char **argv)
+{
+ FAIL_UNLESS(testJmpbuf);
+ return kPassed;
+}
diff --git a/tests/bionic/libstdc++/test_csignal.cpp b/tests/bionic/libstdc++/test_csignal.cpp
new file mode 100644
index 00000000..22fa946f
--- /dev/null
+++ b/tests/bionic/libstdc++/test_csignal.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <csignal>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSIGNAL__
+#error "Wrong header file included!!"
+#endif
+
+namespace {
+const int kPassed = 0;
+const int kFailed = 1;
+#define FAIL_UNLESS(f) if (!android::f()) return kFailed;
+} // anonymous namespace
+
+namespace android
+{
+#ifdef raise
+#error "raise must not be a macro"
+#endif
+
+#ifndef SIGABRT
+#error "SIGABRT must be a macro"
+#endif
+
+#ifndef SIGILL
+#error "SIGILL must be a macro"
+#endif
+
+using std::raise;
+using std::signal;
+bool testSigAtomicT()
+{
+ volatile std::sig_atomic_t s;
+ return true;
+}
+
+} // namespace android
+
+int main(int argc, char **argv)
+{
+ FAIL_UNLESS(testSigAtomicT);
+ return kPassed;
+}
diff --git a/tests/bionic/libstdc++/test_cstddef.cpp b/tests/bionic/libstdc++/test_cstddef.cpp
index e918c589..19f9d422 100644
--- a/tests/bionic/libstdc++/test_cstddef.cpp
+++ b/tests/bionic/libstdc++/test_cstddef.cpp
@@ -26,9 +26,11 @@
* SUCH DAMAGE.
*/
-// Test that including cstddef works. This should be the only include in this
-// file to make sure that we don't pick definitions without us knowing.
#include <cstddef>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDDEF__
+#error "Wrong header file included!!"
+#endif
+
namespace {
const int kPassed = 0;
diff --git a/tests/bionic/libstdc++/test_cstdint.cpp b/tests/bionic/libstdc++/test_cstdint.cpp
new file mode 100644
index 00000000..8753cf7d
--- /dev/null
+++ b/tests/bionic/libstdc++/test_cstdint.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <cstdint>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDINT__
+#error "Wrong header file included!!"
+#endif
+
+namespace {
+const int kPassed = 0;
+} // anonymous namespace
+
+namespace android
+{
+} // namespace android
+
+int main(int argc, char **argv)
+{
+ return kPassed;
+}
diff --git a/tests/bionic/libstdc++/test_cstdio.cpp b/tests/bionic/libstdc++/test_cstdio.cpp
new file mode 100644
index 00000000..573746dc
--- /dev/null
+++ b/tests/bionic/libstdc++/test_cstdio.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <cstdio>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDIO__
+#error "Wrong header file included!!"
+#endif
+
+namespace {
+const int kPassed = 0;
+const int kFailed = 1;
+#define FAIL_UNLESS(f) if (!android::f()) return kFailed;
+} // anonymous namespace
+
+namespace android
+{
+#ifndef BUFSIZ
+#error "BUFSIZ must be a macro"
+#endif
+
+#ifndef EOF
+#error "EOF must be a macro"
+#endif
+
+#ifndef FILENAME_MAX
+#error "FILENAME_MAX must be a macro"
+#endif
+
+#ifndef FOPEN_MAX
+#error "FOPEN_MAX must be a macro"
+#endif
+
+#ifndef L_tmpnam
+#error "L_tmpnam must be a macro"
+#endif
+
+#ifndef NULL
+#error "NULL must be a macro"
+#endif
+
+#ifndef SEEK_CUR
+#error "SEEK_CUR must be a macro"
+#endif
+
+#ifndef SEEK_END
+#error "SEEK_END must be a macro"
+#endif
+#ifndef SEEK_SET
+#error "SEEK_SET must be a macro"
+#endif
+
+#ifndef TMP_MAX
+#error "TMP_MAX must be a macro"
+#endif
+
+#ifndef _IOFBF
+#error "_IOFBF must be a macro"
+#endif
+
+#ifndef _IOLBF
+#error "_IOLBF must be a macro"
+#endif
+
+#ifndef _IONBF
+#error "_IONBF must be a macro"
+#endif
+
+#ifndef stderr
+#error "stderr must be a macro"
+#endif
+
+#ifndef stdin
+#error "stdin must be a macro"
+#endif
+
+#ifndef stdout
+#error "stdout must be a macro"
+#endif
+
+using std::clearerr;
+using std::fclose;
+using std::feof;
+using std::ferror;
+using std::fflush;
+using std::fgetc;
+using std::fgetpos;
+using std::fgets;
+using std::fopen;
+using std::fprintf;
+using std::fputc;
+using std::fputs;
+using std::fread;
+using std::freopen;
+using std::fscanf;
+using std::fseek;
+using std::fsetpos;
+using std::ftell;
+using std::fwrite;
+using std::getc;
+using std::getchar;
+using std::gets;
+using std::perror;
+using std::printf;
+using std::putc;
+using std::putchar;
+using std::puts;
+using std::remove;
+using std::rename;
+using std::rewind;
+using std::scanf;
+using std::setbuf;
+using std::setvbuf;
+using std::sprintf;
+using std::sscanf;
+using std::tmpfile;
+using std::tmpnam;
+using std::ungetc;
+using std::vfprintf;
+using std::vprintf;
+using std::vsprintf;
+
+using std::snprintf;
+using std::vfscanf;
+using std::vscanf;
+using std::vsnprintf;
+using std::vsscanf;
+
+bool testTypesStd()
+{
+ volatile std::size_t size;
+ volatile std::FILE file;
+ volatile std::fpos_t fpos_t;
+ return true;
+}
+} // namespace android
+
+int main(int argc, char **argv)
+{
+ FAIL_UNLESS(testTypesStd);
+ return kPassed;
+}
diff --git a/tests/bionic/libstdc++/test_cstdlib.cpp b/tests/bionic/libstdc++/test_cstdlib.cpp
new file mode 100644
index 00000000..c5c914c4
--- /dev/null
+++ b/tests/bionic/libstdc++/test_cstdlib.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <cstdlib>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CSTDLIB__
+#error "Wrong header file included!!"
+#endif
+
+
+namespace {
+const int kPassed = 0;
+const int kFailed = 1;
+#define FAIL_UNLESS(f) if (!android::f()) return kFailed;
+} // anonymous namespace
+
+namespace android
+{
+} // namespace android
+
+int main(int argc, char **argv)
+{
+ // FAIL_UNLESS(testTypesStd);
+ return kPassed;
+}
diff --git a/tests/bionic/libstdc++/test_ctime.cpp b/tests/bionic/libstdc++/test_ctime.cpp
index f812b312..72a13cb9 100644
--- a/tests/bionic/libstdc++/test_ctime.cpp
+++ b/tests/bionic/libstdc++/test_ctime.cpp
@@ -27,6 +27,10 @@
*/
#include <ctime>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CTIME__
+#error "Wrong header file included!!"
+#endif
+
namespace {
const int kPassed = 0;