}
bool
-hash_command_output(Context& ctx,
- struct hash* hash,
+hash_command_output(struct hash* hash,
const char* command,
const char* compiler)
{
free((char*)command); // Original argument was replaced above.
}
if (ret == 0) {
- stats_update(ctx, STATS_COMPCHECK);
return false;
}
int fd = _open_osfhandle((intptr_t)pipe_out[0], O_BINARY);
bool ok = hash_fd(hash, fd);
if (!ok) {
cc_log("Error hashing compiler check command output: %s", strerror(errno));
- stats_update(ctx, STATS_COMPCHECK);
}
WaitForSingleObject(pi.hProcess, INFINITE);
DWORD exitcode;
CloseHandle(pi.hThread);
if (exitcode != 0) {
cc_log("Compiler check command returned %d", (int)exitcode);
- stats_update(ctx, STATS_COMPCHECK);
return false;
}
return ok;
if (!ok) {
cc_log("Error hashing compiler check command output: %s",
strerror(errno));
- stats_update(ctx, STATS_COMPCHECK);
}
close(pipefd[0]);
}
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
cc_log("Compiler check command returned %d", WEXITSTATUS(status));
- stats_update(ctx, STATS_COMPCHECK);
return false;
}
return ok;
}
bool
-hash_multicommand_output(Context& ctx,
- struct hash* hash,
+hash_multicommand_output(struct hash* hash,
const char* commands,
const char* compiler)
{
char* saveptr = NULL;
bool ok = true;
while ((command = strtok_r(p, ";", &saveptr))) {
- if (!hash_command_output(ctx, hash, command, compiler)) {
+ if (!hash_command_output(hash, command, compiler)) {
ok = false;
}
p = NULL;
TEST(hash_command_output_simple)
{
- Context ctx;
-
char d1[DIGEST_STRING_BUFFER_SIZE];
char d2[DIGEST_STRING_BUFFER_SIZE];
struct hash* h1 = hash_init();
struct hash* h2 = hash_init();
- CHECK(hash_command_output(ctx, h1, "echo", "not used"));
- CHECK(hash_command_output(ctx, h2, "echo", "not used"));
+ CHECK(hash_command_output(h1, "echo", "not used"));
+ CHECK(hash_command_output(h2, "echo", "not used"));
hash_result_as_string(h1, d1);
hash_result_as_string(h2, d2);
CHECK_STR_EQ(d1, d2);
struct hash* h1 = hash_init();
struct hash* h2 = hash_init();
- CHECK(hash_command_output(ctx, h1, "echo", "not used"));
- CHECK(hash_command_output(ctx, h2, " echo ", "not used"));
+ CHECK(hash_command_output(h1, "echo", "not used"));
+ CHECK(hash_command_output(h2, " echo ", "not used"));
hash_result_as_string(h1, d1);
hash_result_as_string(h2, d2);
CHECK_STR_EQ(d1, d2);
struct hash* h1 = hash_init();
struct hash* h2 = hash_init();
- CHECK(hash_command_output(ctx, h1, "echo foo", "not used"));
- CHECK(hash_command_output(ctx, h2, "echo bar", "not used"));
+ CHECK(hash_command_output(h1, "echo foo", "not used"));
+ CHECK(hash_command_output(h2, "echo bar", "not used"));
hash_result_as_string(h1, d1);
hash_result_as_string(h2, d2);
CHECK(!str_eq(d1, d2));
struct hash* h1 = hash_init();
struct hash* h2 = hash_init();
- CHECK(hash_command_output(ctx, h1, "echo foo", "not used"));
- CHECK(hash_command_output(ctx, h2, "%compiler% foo", "echo"));
+ CHECK(hash_command_output(h1, "echo foo", "not used"));
+ CHECK(hash_command_output(h2, "%compiler% foo", "echo"));
hash_result_as_string(h1, d1);
hash_result_as_string(h2, d2);
CHECK_STR_EQ(d1, d2);
#ifndef _WIN32
create_file("stderr.sh", "#!/bin/sh\necho foo >&2\n");
chmod("stderr.sh", 0555);
- CHECK(hash_command_output(ctx, h1, "echo foo", "not used"));
- CHECK(hash_command_output(ctx, h2, "./stderr.sh", "not used"));
+ CHECK(hash_command_output(h1, "echo foo", "not used"));
+ CHECK(hash_command_output(h2, "./stderr.sh", "not used"));
#else
create_file("stderr.bat", "@echo off\r\necho foo>&2\r\n");
- CHECK(hash_command_output(ctx, h1, "echo foo", "not used"));
- CHECK(hash_command_output(ctx, h2, "stderr.bat", "not used"));
+ CHECK(hash_command_output(h1, "echo foo", "not used"));
+ CHECK(hash_command_output(h2, "stderr.bat", "not used"));
#endif
hash_result_as_string(h1, d1);
hash_result_as_string(h2, d2);
#ifndef _WIN32
create_file("foo.sh", "#!/bin/sh\necho foo\necho bar\n");
chmod("foo.sh", 0555);
- CHECK(hash_multicommand_output(ctx, h2, "echo foo; echo bar", "not used"));
- CHECK(hash_multicommand_output(ctx, h1, "./foo.sh", "not used"));
+ CHECK(hash_multicommand_output(h2, "echo foo; echo bar", "not used"));
+ CHECK(hash_multicommand_output(h1, "./foo.sh", "not used"));
#else
create_file("foo.bat", "@echo off\r\necho foo\r\necho bar\r\n");
- CHECK(hash_multicommand_output(ctx, h2, "echo foo; echo bar", "not used"));
- CHECK(hash_multicommand_output(ctx, h1, "foo.bat", "not used"));
+ CHECK(hash_multicommand_output(h2, "echo foo; echo bar", "not used"));
+ CHECK(hash_multicommand_output(h1, "foo.bat", "not used"));
#endif
hash_result_as_string(h1, d1);
hash_result_as_string(h2, d2);
struct hash* h1 = hash_init();
struct hash* h2 = hash_init();
- CHECK(!hash_multicommand_output(ctx, h2, "false; true", "not used"));
+ CHECK(!hash_multicommand_output(h2, "false; true", "not used"));
hash_free(h2);
hash_free(h1);