LLVM LIT without IO/FileCheck (original) (raw)
November 5, 2024, 6:26am 1
Hi there,
I am writing some test cases for my LLVM project. For some reasons, I can’t use IO during the test. Instead, I can use return value to check if test is success or not. I know each test case’s expected return value. So by comparing the expected and real return value, I can tell the test result.
However, I am not sure if LIT support this approach. In most cases, non-zero return value is treated as failure. Also, I saw many test cases are using FileCheck to compare the IO result. Is it possible to compare result using return value?
tianboh November 5, 2024, 7:17am 2
Oh, I figured it out. For test file
// RUN: python3 %S/driver.py
For driver.py
import sys
def main():
do the test and compare
if success:
sys.exit(0)
else
sys.exit(1)
if __name__ == "__main__":
main()