summaryrefslogtreecommitdiff
path: root/libdexfile/external/dex_file_ext_c_test.c
diff options
context:
space:
mode:
authorDavid Srbecky <dsrbecky@google.com>2021-03-24 16:11:49 +0000
committerDavid Srbecky <dsrbecky@google.com>2021-04-21 18:57:13 +0000
commit30d4d2f8dba0d7cd29cb0eeee53883d73542b7cc (patch)
treef670c2fed029ac132b1be91544bd470310f66efc /libdexfile/external/dex_file_ext_c_test.c
parent18584d13da8af452c79e3909617f969fc1f3f455 (diff)
Rewrite libdexfile C API to follow NDK guidelines better.
Bug: 123517037 Bug: 145347927 Test: test-art-host-gtest-art_libdexfile_support_tests64 Test: test-art-host-gtest-art_libdexfile_external_tests64 Change-Id: I9673872585456937d2f54abb63e3dbd8aad4e9ad
Diffstat (limited to 'libdexfile/external/dex_file_ext_c_test.c')
-rw-r--r--libdexfile/external/dex_file_ext_c_test.c64
1 files changed, 2 insertions, 62 deletions
diff --git a/libdexfile/external/dex_file_ext_c_test.c b/libdexfile/external/dex_file_ext_c_test.c
index e1139718dd..656a6cb9b1 100644
--- a/libdexfile/external/dex_file_ext_c_test.c
+++ b/libdexfile/external/dex_file_ext_c_test.c
@@ -14,66 +14,6 @@
* limitations under the License.
*/
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-
-/* The main purpose of this test is to ensure this C header compiles in C, so
- * that no C++ features inadvertently leak into the C ABI. */
+/* The main purpose of this file is to ensure this C header compiles in C,
+ * so that no C++ features inadvertently leak into the C ABI. */
#include "art_api/dex_file_external.h"
-
-static const char gtest_output_arg[] = "--gtest_output=xml:";
-static const char gtest_output_xml[] = "\
-<?xml version=\"1.0\"?>\n\
-<testsuites tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" name=\"AllTests\">\n\
- <testsuite tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" name=\"NopTest\">\n\
- <testcase name=\"nop\" status=\"run\" />\n\
- </testsuite>\n\
-</testsuites>";
-
-static const char canned_stdout[] = "\
-[==========] Running 1 test from 1 test suite.\n\
-[----------] 1 test from NopTest\n\
-[ RUN ] NopTest.nop\n\
-[ OK ] NopTest.nop (0 ms)\n\
-[----------] 1 test from NopTest (0 ms total)\n\
-\n\
-[==========] 1 test from 1 test suite ran. (0 ms total)\n\
-[ PASSED ] 1 test.\n\
-";
-
-/* Writes a fake gtest xml report to the given path. */
-static int write_gtest_output_xml(char* gtest_output_path) {
- FILE* output_fd = fopen(gtest_output_path, "w");
- if (output_fd == NULL) {
- fprintf(stderr, "Failed to open %s: %s\n", gtest_output_path, strerror(errno));
- return 1;
- }
- if (fprintf(output_fd, gtest_output_xml) != sizeof(gtest_output_xml) - 1) {
- fprintf(stderr, "Failed to write %s: %s\n", gtest_output_path, strerror(errno));
- fclose(output_fd);
- return 1;
- }
- if (fclose(output_fd) != 0) {
- fprintf(stderr, "Failed to close %s: %s\n", gtest_output_path, strerror(errno));
- return 1;
- }
- return 0;
-}
-
-int main(int argc, char** argv) {
- int i;
- for (i = 1; i < argc; ++i) {
- if (strncmp(argv[i], gtest_output_arg, sizeof(gtest_output_arg) - 1) == 0) {
- /* The ART gtest framework expects all tests to understand --gtest_output. */
- if (write_gtest_output_xml(argv[i] + sizeof(gtest_output_arg) - 1)) {
- return 1;
- }
- }
- }
- /* Tradefed parses the output, so send something passable there. */
- if (fputs(canned_stdout, stdout) < 0) {
- return 1;
- }
- return 0;
-}