Skip to content

Commit

Permalink
Use /VA instead of /V5 for the APX prefix
Browse files Browse the repository at this point in the history
Signed-off-by: William Douglas <[email protected]>
  • Loading branch information
bryteise committed Jan 30, 2024
1 parent 66e4b93 commit bb53ba0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
10 changes: 5 additions & 5 deletions swupd/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ var modifierPrefixes = map[ModifierFlag]string{
Avx512_3: "/V4",
Avx512_6: "/V4",
Avx512_7: "/V4",
Apx4: "/V5",
Apx5: "/V5",
Apx6: "/V5",
Apx7: "/V5",
Apx4: "/VA",
Apx5: "/VA",
Apx6: "/VA",
Apx7: "/VA",
}

// The three maps below were generated using the following:
Expand Down Expand Up @@ -484,5 +484,5 @@ func (f *File) Present() bool {
}

func (f *File) hasOptPrefix() bool {
return strings.HasPrefix(f.Name, "/V3") || strings.HasPrefix(f.Name, "/V4") || strings.HasPrefix(f.Name, "/V5")
return strings.HasPrefix(f.Name, "/V3") || strings.HasPrefix(f.Name, "/V4") || strings.HasPrefix(f.Name, "/VA")
}
2 changes: 1 addition & 1 deletion swupd/heuristics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package swupd
import "strings"

func (f *File) setModifierFromPathname() {
temp := strings.TrimPrefix(f.Name, "/V5")
temp := strings.TrimPrefix(f.Name, "/VA")
if temp != f.Name {
f.Modifier = Apx4
f.Name = temp
Expand Down
2 changes: 1 addition & 1 deletion swupd/heuristics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestSetModifierFromPathname(t *testing.T) {
}{
{File{Name: "/V3/etc/file"}, "/etc/file", Avx2_1},
{File{Name: "/V4/usr/src/debug"}, "/usr/src/debug", Avx512_2},
{File{Name: "/V5/usr/bin/foo"}, "/usr/bin/foo", Apx4},
{File{Name: "/VA/usr/bin/foo"}, "/usr/bin/foo", Apx4},
{File{Name: "/dev/foo"}, "/dev/foo", Sse0},
}

Expand Down
6 changes: 3 additions & 3 deletions swupd/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ func (m *Manifest) removeOptNonFiles() {
// Looking files files, deleted files or anything else that doesn't have an
// optimization prefix.
if f.Status == StatusDeleted {
if strings.HasPrefix(f.Name, "/V3") || strings.HasPrefix(f.Name, "/V4") || strings.HasPrefix(f.Name, "/V5") {
if strings.HasPrefix(f.Name, "/V3") || strings.HasPrefix(f.Name, "/V4") || strings.HasPrefix(f.Name, "/VA") {
// for non-SSE deleted files the versions on matching files need bumping
// so update will replace the deleted optimized file.
// Track these files for later
strippedName := strings.TrimPrefix(f.Name, "/V3")
strippedName = strings.TrimPrefix(strippedName, "/V4")
strippedName = strings.TrimPrefix(strippedName, "/V5")
strippedName = strings.TrimPrefix(strippedName, "/VA")
seen[strippedName] = true
continue
}
Expand All @@ -329,7 +329,7 @@ func (m *Manifest) removeOptNonFiles() {
for _, f := range m.Files {
strippedName := strings.TrimPrefix(f.Name, "/V3")
strippedName = strings.TrimPrefix(strippedName, "/V4")
strippedName = strings.TrimPrefix(strippedName, "/V5")
strippedName = strings.TrimPrefix(strippedName, "/VA")
// Only SSE content or non-deleted optimized files should be added to the filelist
if result := seen[strippedName]; result {
// Now update any versions for matching files of newly deleted optimized files
Expand Down
46 changes: 23 additions & 23 deletions swupd/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,13 @@ func TestRemoveOptNonFiles(t *testing.T) {
testCases := []File{
{Name: "/V3/", Type: TypeLink},
{Name: "/V4", Type: TypeDirectory},
{Name: "/V5", Type: TypeDirectory},
{Name: "/VA", Type: TypeDirectory},
{Name: "/V3/usr/bin/f1", Type: TypeUnset, Status: StatusDeleted},
{Name: "/V4/usr/bin/f2", Type: TypeUnset, Status: StatusDeleted},
{Name: "/V5/usr/bin/f3", Type: TypeUnset, Status: StatusDeleted},
{Name: "/VA/usr/bin/f3", Type: TypeUnset, Status: StatusDeleted},
{Name: "/V3/usr/bin/f4-1", Type: TypeUnset, Status: StatusDeleted},
{Name: "/V4/usr/bin/f4-2", Type: TypeUnset, Status: StatusDeleted},
{Name: "/V5/usr/bin/f4-3", Type: TypeUnset, Status: StatusDeleted},
{Name: "/VA/usr/bin/f4-3", Type: TypeUnset, Status: StatusDeleted},
{Name: "/usr/bin/foo", Type: TypeUnset, Status: StatusDeleted},
{Name: "/usr/bin/bar", Type: TypeUnset, Status: StatusDeleted},
{Name: "/usr/bin/f1", Type: TypeFile, Version: 10},
Expand All @@ -354,7 +354,7 @@ func TestRemoveOptNonFiles(t *testing.T) {
{Name: "/usr/bin/f4-3", Type: TypeFile, Version: 10},
{Name: "/V3/usr/bin/f4-1", Type: TypeFile, Version: 10},
{Name: "/V4/usr/bin/f4-2", Type: TypeFile, Version: 10},
{Name: "/V5/usr/bin/f4-3", Type: TypeFile, Version: 10},
{Name: "/VA/usr/bin/f4-3", Type: TypeFile, Version: 10},
{Name: "/usr/bin/aa1-mixer-test-canary-2", Type: TypeFile},
{Name: "/V4/usr/bin/aa1-mixer-test-canary-2", Type: TypeFile},
{Name: "/usr/bin/", Type: TypeDirectory},
Expand All @@ -375,7 +375,7 @@ func TestRemoveOptNonFiles(t *testing.T) {
t.Errorf("Manifest file incorrectly pruned, expected: %v | actual: %v",
testCases[i+3].Name, m.Files[i].Name)
}
if (m.Files[i].Name == "/V3/usr/bin/f1" || m.Files[i].Name == "/V4/usr/bin/f2" || m.Files[i].Name == "/V5/usr/bin/f3") && m.Files[i].Version == 20 {
if (m.Files[i].Name == "/V3/usr/bin/f1" || m.Files[i].Name == "/V4/usr/bin/f2" || m.Files[i].Name == "/VA/usr/bin/f3") && m.Files[i].Version == 20 {
t.Errorf("Improperly updated version in %v",
m.Files[i])
}
Expand All @@ -400,7 +400,7 @@ func TestSetupModifiers(t *testing.T) {
{File{Name: "/usr/bin", Type: TypeDirectory, Misc: MiscExportFile, Status: StatusExperimental}, "/usr/bin", Sse0, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/V3/usr/bin", Type: TypeDirectory}, "/usr/bin", Avx2_1, MiscUnset, StatusUnset, 0, false, true},
{File{Name: "/V4/usr/bin", Type: TypeDirectory}, "/usr/bin", Avx512_2, MiscUnset, StatusUnset, 0, false, true},
{File{Name: "/V5/usr/bin", Type: TypeDirectory}, "/usr/bin", Apx4, MiscUnset, StatusUnset, 0, false, true},
{File{Name: "/VA/usr/bin", Type: TypeDirectory}, "/usr/bin", Apx4, MiscUnset, StatusUnset, 0, false, true},
{File{Name: "/usr/bin/file00", Type: TypeFile, Misc: MiscExportFile, Status: StatusExperimental}, "/usr/bin/file00", Sse0, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/usr/bin/file01", Type: TypeFile, Misc: MiscExportFile, Status: StatusExperimental}, "/usr/bin/file01", Sse1, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/usr/bin/file02", Type: TypeFile, Misc: MiscExportFile, Status: StatusExperimental}, "/usr/bin/file02", Sse2, MiscExportFile, StatusExperimental, 0, false, false},
Expand All @@ -417,10 +417,10 @@ func TestSetupModifiers(t *testing.T) {
{File{Name: "/V4/usr/bin/file03", Type: TypeFile, Modifier: Avx512_2}, "/usr/bin/file03", Avx512_3, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/V4/usr/bin/file06", Type: TypeFile, Modifier: Avx512_2}, "/usr/bin/file06", Avx512_6, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/V4/usr/bin/file07", Type: TypeFile, Modifier: Avx512_2}, "/usr/bin/file07", Avx512_7, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/V5/usr/bin/file04", Type: TypeFile, Modifier: Apx4}, "/usr/bin/file04", Apx4, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/V5/usr/bin/file05", Type: TypeFile, Modifier: Apx4}, "/usr/bin/file05", Apx5, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/V5/usr/bin/file06", Type: TypeFile, Modifier: Apx4}, "/usr/bin/file06", Apx6, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/V5/usr/bin/file07", Type: TypeFile, Modifier: Apx4}, "/usr/bin/file07", Apx7, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/VA/usr/bin/file04", Type: TypeFile, Modifier: Apx4}, "/usr/bin/file04", Apx4, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/VA/usr/bin/file05", Type: TypeFile, Modifier: Apx4}, "/usr/bin/file05", Apx5, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/VA/usr/bin/file06", Type: TypeFile, Modifier: Apx4}, "/usr/bin/file06", Apx6, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/VA/usr/bin/file07", Type: TypeFile, Modifier: Apx4}, "/usr/bin/file07", Apx7, MiscExportFile, StatusExperimental, 0, false, false},
{File{Name: "/usr/bin/dfile00", Type: TypeFile, Misc: MiscExportFile, Status: StatusUnset}, "/usr/bin/dfile00", Sse0, MiscExportFile, StatusUnset, 0, false, false},
{File{Name: "/usr/bin/dfile01", Type: TypeFile, Misc: MiscExportFile, Status: StatusUnset}, "/usr/bin/dfile01", Sse0, MiscExportFile, StatusUnset, 20, false, false},
{File{Name: "/V3/usr/bin/dfile01", Type: TypeUnset, Misc: MiscExportFile, Status: StatusDeleted}, "/usr/bin/dfile01", Sse0, MiscExportFile, StatusDeleted, 0, false, true},
Expand All @@ -431,7 +431,7 @@ func TestSetupModifiers(t *testing.T) {
{File{Name: "/V4/usr/bin/dfile03", Type: TypeUnset, Misc: MiscExportFile, Status: StatusDeleted}, "/usr/bin/dfile03", Sse0, MiscExportFile, StatusDeleted, 0, false, true},
{File{Name: "/usr/bin/dfile04", Type: TypeFile, Misc: MiscExportFile, Status: StatusUnset}, "/usr/bin/dfile04", Sse2, MiscExportFile, StatusUnset, 20, false, false},
{File{Name: "/V4/usr/bin/dfile04", Type: TypeFile, Misc: MiscExportFile, Status: StatusUnset}, "/usr/bin/dfile04", Avx512_2, MiscExportFile, StatusUnset, 20, false, false},
{File{Name: "/V5/usr/bin/dfile04", Type: TypeUnset, Misc: MiscExportFile, Status: StatusDeleted}, "/usr/bin/dfile04", Sse0, MiscExportFile, StatusDeleted, 0, false, true},
{File{Name: "/VA/usr/bin/dfile04", Type: TypeUnset, Misc: MiscExportFile, Status: StatusDeleted}, "/usr/bin/dfile04", Sse0, MiscExportFile, StatusDeleted, 0, false, true},
}
testCaseMap := make(map[string][]struct {
file File
Expand Down Expand Up @@ -498,7 +498,7 @@ func TestSetupModifiersMissingSSE(t *testing.T) {
testCases := []File{
{Name: "/V3/usr/bin/file00", Type: TypeFile, Modifier: Avx2_1},
{Name: "/V4/usr/bin/file01", Type: TypeFile, Modifier: Avx512_2},
{Name: "/V5/usr/bin/file02", Type: TypeFile, Modifier: Apx4},
{Name: "/VA/usr/bin/file02", Type: TypeFile, Modifier: Apx4},
}

for i := range testCases {
Expand Down Expand Up @@ -573,8 +573,8 @@ func TestLinkPeersAndChange(t *testing.T) {
{Name: "/V3/b", Status: StatusUnset, Info: sizer(0), Misc: MiscExportFile, Version: 10},
{Name: "/V4/a", Status: StatusUnset, Info: sizer(0), Misc: MiscExportFile, Version: 10},
{Name: "/V4/b", Status: StatusUnset, Info: sizer(0), Misc: MiscExportFile, Version: 10},
{Name: "/V5/a", Status: StatusUnset, Info: sizer(0), Misc: MiscExportFile, Version: 10},
{Name: "/V5/b", Status: StatusUnset, Info: sizer(0), Misc: MiscExportFile, Version: 10},
{Name: "/VA/a", Status: StatusUnset, Info: sizer(0), Misc: MiscExportFile, Version: 10},
{Name: "/VA/b", Status: StatusUnset, Info: sizer(0), Misc: MiscExportFile, Version: 10},
{Name: "/dir", Type: TypeDirectory, Status: StatusUnset, Info: sizer(0), Version: 10},
{Name: "1", Status: StatusUnset, Info: sizer(0)},
{Name: "2", Status: StatusDeleted, Info: sizer(0)},
Expand All @@ -594,9 +594,9 @@ func TestLinkPeersAndChange(t *testing.T) {
{Name: "/V4/a", Status: StatusUnset, Info: sizer(0)},
{Name: "/V4/b", Status: StatusUnset, Hash: 2, Info: sizer(0)},
{Name: "/V4/dir", Type: TypeDirectory, Status: StatusUnset, Hash: 2, Info: sizer(0)},
{Name: "/V5/a", Status: StatusUnset, Info: sizer(0)},
{Name: "/V5/b", Status: StatusUnset, Hash: 2, Info: sizer(0)},
{Name: "/V5/dir", Type: TypeDirectory, Status: StatusUnset, Hash: 2, Info: sizer(0)},
{Name: "/VA/a", Status: StatusUnset, Info: sizer(0)},
{Name: "/VA/b", Status: StatusUnset, Hash: 2, Info: sizer(0)},
{Name: "/VA/dir", Type: TypeDirectory, Status: StatusUnset, Hash: 2, Info: sizer(0)},
{Name: "/dir", Type: TypeDirectory, Status: StatusUnset, Hash: 3, Info: sizer(0)},
{Name: "1", Status: StatusUnset, Hash: 1, Info: sizer(0)},
{Name: "2", Status: StatusUnset, Info: sizer(0)},
Expand All @@ -618,9 +618,9 @@ func TestLinkPeersAndChange(t *testing.T) {
{Name: "/V4/a", Status: StatusUnset, Info: sizer(0), Version: 10},
{Name: "/V4/b", Status: StatusUnset, Hash: 2, Info: sizer(0)},
{Name: "/V4/dir", Hash: 2},
{Name: "/V5/a", Status: StatusUnset, Info: sizer(0), Version: 10},
{Name: "/V5/b", Status: StatusUnset, Hash: 2, Info: sizer(0)},
{Name: "/V5/dir", Hash: 3},
{Name: "/VA/a", Status: StatusUnset, Info: sizer(0), Version: 10},
{Name: "/VA/b", Status: StatusUnset, Hash: 2, Info: sizer(0)},
{Name: "/VA/dir", Hash: 3},
{Name: "/dir", Type: TypeDirectory, Status: StatusUnset, Hash: 3, Info: sizer(0)},
{Name: "1", Status: StatusUnset, Hash: 1, Info: sizer(0)},
{Name: "2", Status: StatusUnset, Info: sizer(0)},
Expand All @@ -643,13 +643,13 @@ func TestLinkPeersAndChange(t *testing.T) {
"6": {false, ""},
"/V3/a": {false, ""},
"/V4/a": {false, ""},
"/V5/a": {false, ""},
"/VA/a": {false, ""},
"/V3/b": {true, "/V3/b"},
"/V4/b": {true, "/V4/b"},
"/V5/b": {true, "/V5/b"},
"/VA/b": {true, "/VA/b"},
"/V3/dir": {false, ""},
"/V4/dir": {false, ""},
"/V5/dir": {false, ""},
"/VA/dir": {false, ""},
"/dir": {true, "/dir"},
}

Expand Down

0 comments on commit bb53ba0

Please sign in to comment.