Fix bug in the test ci script (#15)
This commit is contained in:
parent
baf785cc49
commit
75df02f7a3
@ -100,6 +100,7 @@ def output_matches(output: str, params: Tuple[str]):
|
|||||||
return not errored
|
return not errored
|
||||||
|
|
||||||
def run_command(*args: List[str]):
|
def run_command(*args: List[str]):
|
||||||
|
global failed
|
||||||
print(f"{Fore.CYAN}{Style.BRIGHT}Running Command \"{' '.join(args)}\"{Style.RESET_ALL}")
|
print(f"{Fore.CYAN}{Style.BRIGHT}Running Command \"{' '.join(args)}\"{Style.RESET_ALL}")
|
||||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
@ -110,7 +111,6 @@ def run_command(*args: List[str]):
|
|||||||
print(stdout.decode("utf-8"), end="")
|
print(stdout.decode("utf-8"), end="")
|
||||||
print("stderr:")
|
print("stderr:")
|
||||||
print(stderr.decode("utf-8"), end="")
|
print(stderr.decode("utf-8"), end="")
|
||||||
global failed
|
|
||||||
failed = True
|
failed = True
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
@ -118,6 +118,7 @@ def run_command(*args: List[str]):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def run_test(test_binary, params: Tuple[str]):
|
def run_test(test_binary, params: Tuple[str]):
|
||||||
|
global failed
|
||||||
print(f"{Fore.CYAN}{Style.BRIGHT}Running test{Style.RESET_ALL}")
|
print(f"{Fore.CYAN}{Style.BRIGHT}Running test{Style.RESET_ALL}")
|
||||||
test = subprocess.Popen([test_binary], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
test = subprocess.Popen([test_binary], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
test_stdout, test_stderr = test.communicate()
|
test_stdout, test_stderr = test.communicate()
|
||||||
@ -129,6 +130,7 @@ def run_test(test_binary, params: Tuple[str]):
|
|||||||
print(test_stderr.decode("utf-8"), end="")
|
print(test_stderr.decode("utf-8"), end="")
|
||||||
print("stdout:")
|
print("stdout:")
|
||||||
print(test_stdout.decode("utf-8"), end="")
|
print(test_stdout.decode("utf-8"), end="")
|
||||||
|
failed = True
|
||||||
else:
|
else:
|
||||||
if len(test_stderr) != 0:
|
if len(test_stderr) != 0:
|
||||||
print("stderr:")
|
print("stderr:")
|
||||||
@ -137,7 +139,6 @@ def run_test(test_binary, params: Tuple[str]):
|
|||||||
print(f"{Fore.GREEN}{Style.BRIGHT}Test succeeded{Style.RESET_ALL}")
|
print(f"{Fore.GREEN}{Style.BRIGHT}Test succeeded{Style.RESET_ALL}")
|
||||||
else:
|
else:
|
||||||
print(f"{Fore.RED}{Style.BRIGHT}Test failed{Style.RESET_ALL}")
|
print(f"{Fore.RED}{Style.BRIGHT}Test failed{Style.RESET_ALL}")
|
||||||
global failed
|
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
def build(matrix):
|
def build(matrix):
|
||||||
|
|||||||
@ -262,14 +262,18 @@ namespace cpptrace {
|
|||||||
std::unordered_map<std::string, target_vec> entries;
|
std::unordered_map<std::string, target_vec> entries;
|
||||||
for(std::size_t i = 0; i < dlframes.size(); i++) {
|
for(std::size_t i = 0; i < dlframes.size(); i++) {
|
||||||
const auto& entry = dlframes[i];
|
const auto& entry = dlframes[i];
|
||||||
///fprintf(stderr, "%s %s\n", to_hex(entry.raw_address).c_str(), to_hex(entry.raw_address - entry.obj_base + base).c_str());
|
// If libdl fails to find the shared object for a frame, the path will be empty. I've observed this
|
||||||
entries[entry.obj_path].emplace_back(
|
// on macos when looking up the shared object containing `start`.
|
||||||
to_hex(entry.raw_address - entry.obj_base + get_module_image_base(entry)),
|
if(!entry.obj_path.empty()) {
|
||||||
trace[i]
|
///fprintf(stderr, "%s %s\n", to_hex(entry.raw_address).c_str(), to_hex(entry.raw_address - entry.obj_base + base).c_str());
|
||||||
);
|
entries[entry.obj_path].emplace_back(
|
||||||
// Set what is known for now, and resolutions from addr2line should overwrite
|
to_hex(entry.raw_address - entry.obj_base + get_module_image_base(entry)),
|
||||||
trace[i].filename = entry.obj_path;
|
trace[i]
|
||||||
trace[i].symbol = entry.symbol;
|
);
|
||||||
|
// Set what is known for now, and resolutions from addr2line should overwrite
|
||||||
|
trace[i].filename = entry.obj_path;
|
||||||
|
trace[i].symbol = entry.symbol;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
@ -329,7 +333,7 @@ namespace cpptrace {
|
|||||||
obj_end != std::string::npos,
|
obj_end != std::string::npos,
|
||||||
"Unexpected edge case while processing addr2line/atos output"
|
"Unexpected edge case while processing addr2line/atos output"
|
||||||
);
|
);
|
||||||
const std::size_t filename_start = line.find(") (", obj_end) + 3;
|
const std::size_t filename_start = line.find(") (", obj_end);
|
||||||
if(filename_start == std::string::npos) {
|
if(filename_start == std::string::npos) {
|
||||||
// presumably something like 0x100003b70 (in demo) or foo (in bar) + 14
|
// presumably something like 0x100003b70 (in demo) or foo (in bar) + 14
|
||||||
return;
|
return;
|
||||||
@ -339,7 +343,7 @@ namespace cpptrace {
|
|||||||
filename_end != std::string::npos,
|
filename_end != std::string::npos,
|
||||||
"Unexpected edge case while processing addr2line/atos output"
|
"Unexpected edge case while processing addr2line/atos output"
|
||||||
);
|
);
|
||||||
entries_vec[entry_index].second.get().filename = line.substr(filename_start, filename_end - filename_start);
|
entries_vec[entry_index].second.get().filename = line.substr(filename_start + 3, filename_end - filename_start - 3);
|
||||||
const std::size_t line_start = filename_end + 1;
|
const std::size_t line_start = filename_end + 1;
|
||||||
const std::size_t line_end = line.find(")", filename_end);
|
const std::size_t line_end = line.find(")", filename_end);
|
||||||
internal_verify(
|
internal_verify(
|
||||||
|
|||||||
25
test/expected/macos.addr2line.txt
Normal file
25
test/expected/macos.addr2line.txt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
test.cpp||19||trace()
|
||||||
|
test.cpp||35||foo(int)
|
||||||
|
test.cpp||39||foo(int)
|
||||||
|
test.cpp||39||foo(int)
|
||||||
|
test.cpp||39||foo(int)
|
||||||
|
test.cpp||39||foo(int)
|
||||||
|
test.cpp||39||foo(int)
|
||||||
|
test.cpp||39||foo(int)
|
||||||
|
test.cpp||39||foo(int)
|
||||||
|
test.cpp||39||foo(int)
|
||||||
|
test.cpp||39||foo(int)
|
||||||
|
test.cpp||39||foo(int)
|
||||||
|
test.cpp||47||void foo<int>(int, int)
|
||||||
|
test.cpp||47||void foo<int, int>(int, int, int)
|
||||||
|
test.cpp||47||void foo<int, int, int>(int, int, int, int)
|
||||||
|
test.cpp||47||void foo<int, int, int, int>(int, int, int, int, int)
|
||||||
|
test.cpp||47||void foo<int, int, int, int, int>(int, int, int, int, int, int)
|
||||||
|
test.cpp||47||void foo<int, int, int, int, int, int>(int, int, int, int, int, int, int)
|
||||||
|
test.cpp||47||void foo<int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int)
|
||||||
|
test.cpp||47||void foo<int, int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int, int)
|
||||||
|
test.cpp||47||void foo<int, int, int, int, int, int, int, int, int>(int, int, int, int, int, int, int, int, int, int)
|
||||||
|
test.cpp||53||function_two(int, float)
|
||||||
|
test.cpp||59||function_one(int)
|
||||||
|
test.cpp||65||main
|
||||||
|
||0||
|
||||||
Loading…
Reference in New Issue
Block a user