// Running the Python oracle (sots-re/verify/harness/compare) from a host test. // // The harness directory comes from -DSOTS_TRACECMP_DIR (CMake) or the SOTS_TRACECMP_DIR // environment variable; when neither points at a directory holding tracecmp.py the // python steps are skipped (returning kSkipped) and the test still passes. #pragma once #include #include #include namespace tracetest { constexpr int kSkipped = -1; inline std::string harness_dir() { if (const char* e = std::getenv("SOTS_TRACECMP_DIR"); e && *e) return e; #ifdef SOTS_TRACECMP_DIR return SOTS_TRACECMP_DIR; #else return ""; #endif } inline bool file_exists(const std::string& p) { if (std::FILE* f = std::fopen(p.c_str(), "rb")) { std::fclose(f); return true; } return false; } inline bool harness_present() { return file_exists(harness_dir() + "/tracecmp.py"); } // Exit status of `python3