ATF_TC_BODY(h_build_c_o_fail, tc) { FILE *sfile; bool success; ATF_REQUIRE((sfile = fopen("test.c", "w")) != NULL); fprintf(sfile, "void foo(void) { int a = UNDEFINED_SYMBOL; }\n"); fclose(sfile); RE(atf_check_build_c_o("test.c", "test.o", NULL, &success)); ATF_REQUIRE(!success); }
ATF_TC_BODY(h_build_c_o_ok, tc) { FILE *sfile; bool success; ATF_REQUIRE((sfile = fopen("test.c", "w")) != NULL); fprintf(sfile, "#include <stdio.h>\n"); fclose(sfile); RE(atf_check_build_c_o("test.c", "test.o", NULL, &success)); ATF_REQUIRE(success); }
bool impl::build_c_o(const std::string& sfile, const std::string& ofile, const atf::process::argv_array& optargs) { bool success; atf_error_t err = atf_check_build_c_o(sfile.c_str(), ofile.c_str(), optargs.exec_argv(), &success); if (atf_is_error(err)) throw_atf_error(err); return success; }
bool build_check_c_o(const char *path) { bool success; atf_dynstr_t iflag; const char *optargs[4]; RE(atf_dynstr_init_fmt(&iflag, "-I%s", atf_config_get("atf_includedir"))); optargs[0] = atf_dynstr_cstring(&iflag); optargs[1] = "-Wall"; optargs[2] = "-Werror"; optargs[3] = NULL; RE(atf_check_build_c_o(path, "test.o", optargs, &success)); atf_dynstr_fini(&iflag); return success; }
static void build_check_c_o_aux(const char *path, const char *failmsg) { bool success; atf_dynstr_t iflag; const char *optargs[2]; RE(atf_dynstr_init_fmt(&iflag, "-I%s", atf_config_get("atf_includedir"))); optargs[0] = atf_dynstr_cstring(&iflag); optargs[1] = NULL; RE(atf_check_build_c_o(path, "test.o", optargs, &success)); atf_dynstr_fini(&iflag); if (!success) atf_tc_fail(failmsg); }
bool build_check_c_o(const char *path) { bool success; atf_dynstr_t iflag; const char *optargs[4]; RE(atf_dynstr_init_fmt(&iflag, "-I%s", atf_env_get_with_default( "ATF_INCLUDEDIR", ATF_INCLUDEDIR))); optargs[0] = atf_dynstr_cstring(&iflag); optargs[1] = "-Wall"; optargs[2] = "-Werror"; optargs[3] = NULL; RE(atf_check_build_c_o(path, "test.o", optargs, &success)); atf_dynstr_fini(&iflag); return success; }