-
Notifications
You must be signed in to change notification settings - Fork 3
test: cover arm64 stdlib sysreg cross-target paths #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| //go:build !llgo | ||
| // +build !llgo | ||
|
|
||
| package plan9asm | ||
|
|
||
| import ( | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| const arm64LinuxGNUTriple = "aarch64-unknown-linux-gnu" | ||
|
|
||
| func testGOROOT(t *testing.T) string { | ||
| t.Helper() | ||
| if goroot := os.Getenv("GOROOT"); goroot != "" { | ||
| return goroot | ||
| } | ||
| goroot, err := testGoEnv("GOROOT") | ||
| if err != nil || goroot == "" { | ||
| t.Skip("GOROOT not available") | ||
| } | ||
| return goroot | ||
| } | ||
|
|
||
| func testGoEnv(key string) (string, error) { | ||
| out, err := exec.Command("go", "env", key).CombinedOutput() | ||
| if err != nil { | ||
| return "", err | ||
| } | ||
| return strings.TrimSpace(string(out)), nil | ||
| } | ||
|
|
||
| func compileLLVMToObject(t *testing.T, llc, triple, llName, objName, ll string) { | ||
| t.Helper() | ||
| tmp := t.TempDir() | ||
| llPath := filepath.Join(tmp, llName) | ||
| objPath := filepath.Join(tmp, objName) | ||
| if err := os.WriteFile(llPath, []byte(ll), 0644); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| cmd := exec.Command(llc, "-mtriple="+triple, "-filetype=obj", llPath, "-o", objPath) | ||
| out, err := cmd.CombinedOutput() | ||
| if err != nil { | ||
| s := string(out) | ||
| if llcUnsupportedTarget(s) { | ||
| t.Skipf("llc does not support triple %q: %s", triple, strings.TrimSpace(s)) | ||
| } | ||
| t.Fatalf("llc failed: %v\n%s", err, s) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
TestStdlibInternalRuntimeSys_ARM64_CompileandTestTranslateGoModule_StdlibInternalRuntimeSys_ARM64_Compile(added in this same PR) guardos.ReadFileerrors with anos.IsNotExistcheck and skip gracefully when the file is absent from the GOROOT. This test does not — a stripped or non-standard GOROOT that lackscpu_arm64.swill hard-fail here rather than skip.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in
a7e4d58.TestStdlibInternalCPU_ARM64_Compilenow mirrors theruntime/systests and skips cleanly onos.IsNotExist(err)forinternal/cpu/cpu_arm64.s.