MCPcopy Index your code
hub / github.com/rabbitstack/fibratus / TestConvertDosDevice

Function TestConvertDosDevice

pkg/fs/dev_test.go:60–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58 "Z"}
59
60func TestConvertDosDevice(t *testing.T) {
61 m := NewDevMapper()
62 files := make([]string, 0, len(drives))
63
64 for _, drive := range drives {
65 files = append(files, fmt.Sprintf("%s:\\Windows\\system32\\kernel32.dll", drive))
66 }
67
68 var filename string
69 for i := 0; i < len(drives); i++ {
70 filename = m.Convert(fmt.Sprintf("\\Device\\HarddiskVolume%d\\Windows\\system32\\kernel32.dll", i))
71 if !strings.HasPrefix(filename, "\\Device") {
72 break
73 }
74 }
75 assert.Contains(t, files, filename)
76
77 m.(*mapper).cache["\\Device\\HarddiskVolume1"] = "C:"
78 m.(*mapper).cache["\\Device\\HarddiskVolume5"] = "\\Device\\HarddiskVolume5"
79 m.(*mapper).sysroot = "C:\\Windows"
80
81 var tests = []struct {
82 inputFilename string
83 expectedFilename string
84 }{
85 {"\\Device\\HarddiskVolume1\\Windows\\system32\\kernel32.dll", "C:\\Windows\\system32\\kernel32.dll"},
86 {"\\Device\\HarddiskVolume5\\Windows\\system32\\kernel32.dll", "\\Device\\HarddiskVolume5\\Windows\\system32\\kernel32.dll"},
87 {"\\Device\\vmsmb\\VSMB-{dcc079ae-60ba-4d07-847c-3493609c0870}\\os\\Windows\\System32\\ntdll.dll", "C:\\Windows\\System32\\ntdll.dll"},
88 {"\\SystemRoot\\system32\\drivers\\wd\\WdNisDrv.sys", "C:\\Windows\\system32\\drivers\\wd\\WdNisDrv.sys"},
89 {"\\SYSTEMROOT\\system32\\drivers\\wd\\WdNisDrv.sys", "C:\\Windows\\system32\\drivers\\wd\\WdNisDrv.sys"},
90 {"\\Device\\Mup", "\\Device\\Mup"},
91 }
92
93 for _, tt := range tests {
94 t.Run(tt.inputFilename, func(t *testing.T) {
95 assert.Equal(t, tt.expectedFilename, m.Convert(tt.inputFilename))
96 })
97 }
98}

Callers

nothing calls this directly

Calls 5

ConvertMethod · 0.95
NewDevMapperFunction · 0.85
ContainsMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected