Skip to content

Commit

Permalink
Add test against -march (#1938)
Browse files Browse the repository at this point in the history
* Add a test to prevent -march cflags from being
a part of the generation
  • Loading branch information
8W9aG authored Sep 11, 2024
1 parent e76fc2b commit de795b3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/dockerfile/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,3 +726,34 @@ COPY . /src`
torch==2.3.1
pandas==2.0.3`, string(requirements))
}

func TestGenerateDoesNotContainDangerousCFlags(t *testing.T) {
tmpDir := t.TempDir()

yaml := `
build:
gpu: true
cuda: "11.8"
system_packages:
- ffmpeg
- cowsay
python_packages:
- torch==2.3.1
- pandas==2.0.3
run:
- "cowsay moo"
predict: predict.py:Predictor
`
conf, err := config.FromYAML([]byte(yaml))
require.NoError(t, err)
require.NoError(t, conf.ValidateAndComplete(""))

gen, err := NewGenerator(conf, tmpDir)
require.NoError(t, err)
gen.SetUseCogBaseImage(true)
_, actual, _, err := gen.GenerateModelBaseWithSeparateWeights("r8.im/replicate/cog-test")
require.NoError(t, err)

require.NotContains(t, actual, "-march=native")
require.NotContains(t, actual, "-mtune=native")
}

0 comments on commit de795b3

Please sign in to comment.