Some more tests.

This commit is contained in:
Ian A Mason 2020-10-30 23:53:00 +00:00
parent 99c9e94a5b
commit 34edd90d30

View File

@ -56,28 +56,43 @@ func Test_more_functionality(t *testing.T) {
}
func Test_obscure_functionality(t *testing.T) {
sourceFile := "../data/helloworld.c"
objectFile := "../data/bhello.notanextensionthatwerecognize"
args := []string{"../data/helloworld.c", "-c", "-o", objectFile}
exeFile := "../data/bhello"
opSys := runtime.GOOS
args := []string{sourceFile, "-c", "-o", objectFile}
exitCode := shared.Compile(args, "clang")
if exitCode != 0 {
t.Errorf("Compile of %v returned %v\n", args, exitCode)
} else {
fmt.Println("Compiled OK")
}
ok, err := shared.IsObjectFileForOS(objectFile, runtime.GOOS)
if !ok {
t.Errorf("isObjectFileForOS(%v, %v) = %v (err = %v)\n", objectFile, runtime.GOOS, ok, err)
ok, err := shared.IsObjectFileForOS(sourceFile, opSys)
if ok {
t.Errorf("isObjectFileForOS(%v, %v) = %v\n", sourceFile, opSys, ok)
} else {
fmt.Printf("isObjectFileForOS(%v, %v) = %v\n", objectFile, runtime.GOOS, ok)
fmt.Printf("isObjectFileForOS(%v, %v) = %v (err = %v)\n", sourceFile, opSys, ok, err)
}
args = []string{objectFile, "-o", "../data/bhello"}
ok, err = shared.IsObjectFileForOS(objectFile, opSys)
if !ok {
t.Errorf("isObjectFileForOS(%v, %v) = %v (err = %v)\n", objectFile, opSys, ok, err)
} else {
fmt.Printf("isObjectFileForOS(%v, %v) = %v\n", objectFile, opSys, ok)
}
args = []string{objectFile, "-o", exeFile}
exitCode = shared.Compile(args, "clang")
if exitCode != 0 {
t.Errorf("Compile of %v returned %v\n", args, exitCode)
} else {
fmt.Println("Compiled OK")
}
args = []string{"get-bc", "-v", "../data/bhello"}
ok, err = shared.IsObjectFileForOS(exeFile, opSys)
if ok {
t.Errorf("isObjectFileForOS(%v, %v) = %v\n", exeFile, opSys, ok)
} else {
fmt.Printf("isObjectFileForOS(%v, %v) = %v (err = %v)\n", exeFile, opSys, ok, err)
}
args = []string{"get-bc", "-v", exeFile}
exitCode = shared.Extract(args)
if exitCode != 0 {
t.Errorf("Extraction of %v returned %v\n", args, exitCode)