sylixos-uploader/parser/filepath_paser_test.go

65 lines
2.3 KiB
Go
Raw Normal View History

2024-11-18 17:56:36 +08:00
package parser
import (
"testing"
)
// $(WORKSPACE_xxx) shold be replaced with `pwd` path.
// $(Output) shold be replaced with Release/Debug.
// $(Output) is configured in config.mk in base project as string debug or release.
//#*********************************************************************************************************
//# Debug options (debug or release)
//#*********************************************************************************************************
//DEBUG_LEVEL := release
var (
basePrjUploadDosPath = "$(WORKSPACE_base-research)\\libsylixos\\$(Output)\\strip\\libvpmpdm.so"
basePrjUploadUnixPath = "$(WORKSPACE_base-research)/libsylixos/$(Output)/strip/libvpmpdm.so"
bspPrjUploadPath = "$(WORKSPACE_bsprk3568-master)/Release/bspXSpirit2.bin"
bspKoUploadPath = "$(WORKSPACE_bsprk3568-master)/SylixOS/driver/usb/arm64/usbdrv_rk3568_64.ko"
linuxCptUploadPrjPath = "$(WORKSPACE_libdrv_linux_compat)/$(Output)/strip/linuxcompat.ko"
appPrjUploadPath = "$(WORKSPACE_coreutils)/$(Output)/strip/dd"
testCovertMap = map[string]string{
basePrjUploadDosPath: "$(ProjectPath)/libsylixos/$(Output)/strip/libvpmpdm.so",
basePrjUploadUnixPath: "$(ProjectPath)/libsylixos/$(Output)/strip/libvpmpdm.so",
bspPrjUploadPath: "$(ProjectPath)/Release/bspXSpirit2.bin",
bspKoUploadPath: "$(ProjectPath)/SylixOS/driver/usb/arm64/usbdrv_rk3568_64.ko",
linuxCptUploadPrjPath: "$(ProjectPath)/$(Output)/strip/linuxcompat.ko",
appPrjUploadPath: "$(ProjectPath)/$(Output)/strip/dd",
}
)
func TestConvertFilepath(t *testing.T) {
for xmlLocalPath, yamlLocalPath := range testCovertMap {
tmpPath, err := convertFilepath(xmlLocalPath)
if err != nil {
t.Error(err)
}
if tmpPath != yamlLocalPath {
t.Errorf("convertFilepath faild, got: %s, want: %s.", tmpPath, yamlLocalPath)
}
}
}
func TestGetDebugLevel(t *testing.T) {
level, err := getDebugLevel(basePrjPath)
if err != nil {
t.Error(err)
}
if level != levelRelease {
t.Errorf("Unexpected DEBUG_LEVEL: %s, should be: %s",
level, levelRelease)
}
}
func TestHasOutputField(t *testing.T) {
if !hasOutputField(basePrjUploadDosPath) {
t.Error("basePrjUploadDosPath has $(Output) field, should be true")
}
if hasOutputField(bspPrjUploadPath) {
t.Error("bspPrjUploadPath has not $(Output) field, should be false")
}
}