Skip to content

Commit

Permalink
fix: paths for the elf files, are hardcoded, add temp workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-gang committed May 23, 2024
1 parent 7da7c06 commit df6f9c7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
16 changes: 15 additions & 1 deletion internal/elf_executable/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,29 @@ var inputFiles = []string{

func CreateELFexecutable(randomString string, outputFile string) error {
var concatenatedData []byte
// HACK: This is a workaround to make the paths work for CI
var useParentDirFlag bool

file := inputFiles[0]
stat, err := os.Stat(file)
if err != nil || stat == nil {
useParentDirFlag = true
}

for _, inputFile := range inputFiles {
// FIXME
if useParentDirFlag {
inputFile = strings.Join(strings.Split(inputFile, "/")[2:], "/")
}

binaryData, err := getBinaryDataFromHexFile(inputFile, randomString)
if err != nil {
return fmt.Errorf("CodeCrafters internal error. Unable to read from ELF constituent files: %v", err)
}
concatenatedData = append(concatenatedData, binaryData...)
}

err := os.WriteFile(outputFile, concatenatedData, 0755)
err = os.WriteFile(outputFile, concatenatedData, 0755)
if err != nil {
return fmt.Errorf("CodeCrafters internal error. Failed to write output ELF file: %v", err)
}
Expand Down
1 change: 0 additions & 1 deletion internal/test_helpers/fixtures/base/pass
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Debug = true

[stage-8] Running tests for Stage #8: ip1
[stage-8] Running ./spawn_shell.sh
/workspaces/shell-tester/internal <nil>
[your-program] $
[stage-8] > ./my_exe
[your-program] 384215599859
Expand Down
1 change: 0 additions & 1 deletion internal/test_helpers/fixtures/navigation/pass
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ Debug = true

[stage-8] Running tests for Stage #8: ip1
[stage-8] Running ./spawn_shell.sh
/workspaces/shell-tester/internal <nil>
[your-program] $
[stage-8] > ./my_exe
[your-program] 384215599859
Expand Down

0 comments on commit df6f9c7

Please sign in to comment.