OSDN Git Service

AI 145059: (Almost) final set of wrapper around the C headers for stdc++ and their...
authorNiko Catania <>
Wed, 8 Apr 2009 16:01:38 +0000 (09:01 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Wed, 8 Apr 2009 16:01:38 +0000 (09:01 -0700)
  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

12 files changed:
tests/bionic/libstdc++/Android.mk
tests/bionic/libstdc++/README.TXT
tests/bionic/libstdc++/test_cassert.cpp
tests/bionic/libstdc++/test_cctype.cpp
tests/bionic/libstdc++/test_climits.cpp
tests/bionic/libstdc++/test_csetjmp.cpp [new file with mode: 0644]
tests/bionic/libstdc++/test_csignal.cpp [new file with mode: 0644]
tests/bionic/libstdc++/test_cstddef.cpp
tests/bionic/libstdc++/test_cstdint.cpp [new file with mode: 0644]
tests/bionic/libstdc++/test_cstdio.cpp [new file with mode: 0644]
tests/bionic/libstdc++/test_cstdlib.cpp [new file with mode: 0644]
tests/bionic/libstdc++/test_ctime.cpp

index 4446c87..2151676 100644 (file)
@@ -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
index 90d40ea..aa7f8a4 100644 (file)
@@ -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.
+
index efe73fe..67c96de 100644 (file)
  * 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;
index ad6312b..bedb77f 100644 (file)
  */
 
 #include <cctype>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CCTYPE__
+#error "Wrong header file included!!"
+#endif
+
 
 namespace {
 const int kPassed = 0;
index 2e5c59e..f3ce023 100644 (file)
  * 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 (file)
index 0000000..9b31490
--- /dev/null
@@ -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 (file)
index 0000000..22fa946
--- /dev/null
@@ -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;
+}
index e918c58..19f9d42 100644 (file)
  * 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 (file)
index 0000000..8753cf7
--- /dev/null
@@ -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 (file)
index 0000000..573746d
--- /dev/null
@@ -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 (file)
index 0000000..c5c914c
--- /dev/null
@@ -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;
+}
index f812b31..72a13cb 100644 (file)
  */
 
 #include <ctime>
+#ifndef BIONIC_LIBSTDCPP_INCLUDE_CTIME__
+#error "Wrong header file included!!"
+#endif
+
 
 namespace {
 const int kPassed = 0;