Commit 30ebb9ca authored by WAKAYAMA Shirou's avatar WAKAYAMA Shirou

rename expected dir to testdata.

parent f8ef680a
......@@ -23,7 +23,7 @@ func TestParseDmesgBoot(t *testing.T) {
{"2cpu_4core.txt", 2, 4},
}
for _, tt := range cpuTests {
v, num, err := parseDmesgBoot(filepath.Join("expected/freebsd/", tt.file))
v, num, err := parseDmesgBoot(filepath.Join("testdatak", "freebsd", tt.file))
if err != nil {
t.Errorf("parseDmesgBoot failed(%s), %v", tt.file, err)
}
......
......@@ -16,16 +16,16 @@ func TestParseISAInfo(t *testing.T) {
{
"1cpu_1core_isainfo.txt",
[]string{"rdseed", "adx", "avx2", "fma", "bmi2", "bmi1", "rdrand", "f16c", "vmx",
"avx", "xsave", "pclmulqdq", "aes", "movbe", "sse4.2", "sse4.1", "ssse3", "popcnt",
"tscp", "cx16", "sse3", "sse2", "sse", "fxsr", "mmx", "cmov", "amd_sysc", "cx8",
"tsc", "fpu"},
"avx", "xsave", "pclmulqdq", "aes", "movbe", "sse4.2", "sse4.1", "ssse3", "popcnt",
"tscp", "cx16", "sse3", "sse2", "sse", "fxsr", "mmx", "cmov", "amd_sysc", "cx8",
"tsc", "fpu"},
},
{
"2cpu_1core_isainfo.txt",
[]string{"rdseed", "adx", "avx2", "fma", "bmi2", "bmi1", "rdrand", "f16c", "vmx",
"avx", "xsave", "pclmulqdq", "aes", "movbe", "sse4.2", "sse4.1", "ssse3", "popcnt",
"tscp", "cx16", "sse3", "sse2", "sse", "fxsr", "mmx", "cmov", "amd_sysc", "cx8",
"tsc", "fpu"},
"avx", "xsave", "pclmulqdq", "aes", "movbe", "sse4.2", "sse4.1", "ssse3", "popcnt",
"tscp", "cx16", "sse3", "sse2", "sse", "fxsr", "mmx", "cmov", "amd_sysc", "cx8",
"tsc", "fpu"},
},
{
"2cpu_8core_isainfo.txt",
......@@ -36,7 +36,7 @@ func TestParseISAInfo(t *testing.T) {
}
for _, tc := range cases {
content, err := ioutil.ReadFile(filepath.Join("expected", "solaris", tc.filename))
content, err := ioutil.ReadFile(filepath.Join("testdata", "solaris", tc.filename))
if err != nil {
t.Errorf("cannot read test case: %s", err)
}
......@@ -96,7 +96,7 @@ func TestParseProcessorInfo(t *testing.T) {
}
for _, tc := range cases {
content, err := ioutil.ReadFile(filepath.Join("expected", "solaris", tc.filename))
content, err := ioutil.ReadFile(filepath.Join("testdata", "solaris", tc.filename))
if err != nil {
t.Errorf("cannot read test case: %s", err)
}
......
......@@ -10,6 +10,7 @@ import (
"bufio"
"bytes"
"errors"
"fmt"
"io/ioutil"
"log"
"net/url"
......@@ -41,9 +42,8 @@ func (i Invoke) Command(name string, arg ...string) ([]byte, error) {
}
type FakeInvoke struct {
CommandExpectedDir string // CommandExpectedDir specifies dir which includes expected outputs.
Suffix string // Suffix species expected file name suffix such as "fail"
Error error // If Error specfied, return the error.
Suffix string // Suffix species expected file name suffix such as "fail"
Error error // If Error specfied, return the error.
}
// Command in FakeInvoke returns from expected file if exists.
......@@ -54,22 +54,18 @@ func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error) {
arch := runtime.GOOS
fname := strings.Join(append([]string{name}, arg...), "")
commandName := filepath.Base(name)
fname := strings.Join(append([]string{commandName}, arg...), "")
fname = url.QueryEscape(fname)
var dir string
if i.CommandExpectedDir == "" {
dir = "expected"
} else {
dir = i.CommandExpectedDir
}
fpath := path.Join(dir, arch, fname)
fpath := path.Join("testdata", arch, fname)
if i.Suffix != "" {
fpath += "_" + i.Suffix
}
if PathExists(fpath) {
return ioutil.ReadFile(fpath)
}
return exec.Command(name, arg...).Output()
return []byte{}, fmt.Errorf("could not find testdata: %s", fpath)
}
var ErrNotImplementedError = errors.New("not implemented yet")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment