Skip to content

Commit

Permalink
Always build AuxData interoperability tests with the C++ API
Browse files Browse the repository at this point in the history
  • Loading branch information
jdorn-gt committed Jan 3, 2025
1 parent 9b2358a commit d5c1172
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
4 changes: 1 addition & 3 deletions src/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,4 @@ target_link_libraries(
)

add_subdirectory(testInputBinary)
if(${GTIRB_PY_API})
add_subdirectory(testInterop)
endif()
add_subdirectory(testInterop)
30 changes: 16 additions & 14 deletions src/test/testInterop/test_floats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
//===----------------------------------------------------------------------===//

#include <gtirb/gtirb.hpp>
#include <cstring>
#include <fstream>
#include <iostream>

struct AFloat {
static constexpr const char* Name = "AFloat";
Expand Down Expand Up @@ -55,21 +57,21 @@ void create_floats(const std::string& filename) {
ir->save(out);
}

int usage(const char* argv0) {
std::cout << "Usage: " << argv0 << " {-r filename | -w filename}\n";
return -1;
}

int main(int argc, char** argv) {
if (argc < 2)
return -1;
if (argc < 3)
return usage(argv[0]);
registerAuxData();
std::string filename;
while (auto c = getopt(argc, argv, "r:w:")) {
switch (c) {
case 'w':
create_floats(optarg);
return 0;
case 'r':
return test_floats(optarg);
default:
break;
}
if (strcmp("-w", argv[1]) == 0) {
create_floats(argv[2]);
return 0;
} else if (strcmp("-r", argv[1]) == 0) {
return test_floats(argv[2]);
} else {
return usage(argv[0]);
}
return 0;
}
24 changes: 13 additions & 11 deletions src/test/testInterop/test_variants.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <gtirb/gtirb.hpp>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
Expand Down Expand Up @@ -66,17 +67,18 @@ bool check_ir(const std::string& filename) {
return 0;
}

int usage(const char* argv0) {
std::cout << "Usage: " << argv0 << " {-r filename | -w filename}\n";
return -1;
}

int main(int argc, char** argv) {
if (argc < 3)
return usage(argv[0]);
register_schema();
while (auto c = getopt(argc, argv, "r:w:")) {
switch (c) {
case 'r':
return check_ir(optarg);
case 'w':
return write_ir(optarg);
default:
return 1;
}
}
return 1;
if (strcmp(argv[1], "-r") == 0)
return check_ir(argv[2]);
if (strcmp(argv[1], "-w") == 0)
return write_ir(argv[2]);
return usage(argv[0]);
}

0 comments on commit d5c1172

Please sign in to comment.