diff --git a/.github/workflows/eventlist.yml b/.github/workflows/eventlist.yml index 0d8344e..63bb5fd 100644 --- a/.github/workflows/eventlist.yml +++ b/.github/workflows/eventlist.yml @@ -14,6 +14,10 @@ on: release: types: [published] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: if: | @@ -41,20 +45,10 @@ jobs: languages: go queries: security-and-quality - - name: Create build folder - run: mkdir build - working-directory: ./tools/eventlist - - - name: Generate version information - run: | - go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo - go generate - working-directory: ./tools/eventlist - - name: Build linux-amd64 executable run: | - GOOS=linux GOARCH=amd64 go build -o linux-amd64/eventlist ./.. - working-directory: ./tools/eventlist/build + ./make.sh build -os linux -arch amd64 -outdir build/linux-amd64/eventlist + working-directory: ./tools/eventlist - name: Perform CodeQL Analysis if: github.event_name != 'release' @@ -62,12 +56,11 @@ jobs: - name: Build remaining executables run: | - GOOS=linux GOARCH=arm64 go build -o linux-arm64/eventlist ./.. - GOOS=darwin GOARCH=amd64 go build -o darwin-amd64/eventlist ./.. - GOOS=darwin GOARCH=arm64 go build -o darwin-arm64/eventlist ./.. - GOOS=windows GOARCH=amd64 go build -o windows-amd64/eventlist.exe ./.. - working-directory: ./tools/eventlist/build - + ./make.sh build -os linux -arch arm64 -outdir build/linux-arm64 + ./make.sh build -os darwin -arch amd64 -outdir build/darwin-amd64 + ./make.sh build -os darwin -arch arm64 -outdir build/darwin-arm64 + ./make.sh build -os windows -arch amd64 -outdir build/windows-amd64 + working-directory: ./tools/eventlist - name: Archive eventlist uses: actions/upload-artifact@v3 diff --git a/.gitignore b/.gitignore index aa3f276..4fb8bbc 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ __debug_bin *.bak *.syso *.log +*.out diff --git a/tools/eventlist/README.md b/tools/eventlist/README.md index 9a2ca5e..eaf5b7f 100644 --- a/tools/eventlist/README.md +++ b/tools/eventlist/README.md @@ -35,18 +35,20 @@ Note that some of the required tools are platform dependent: - Platform specific command line terminal - **Windows:** - [GIT Bash](https://gitforwindows.org/) - ``` + + ```txt ☑️ Note: Make sure 'git' and 'bash' paths are listed under the PATH environment variable and set the git bash priority higher in the path. ``` + - **Linux/MacOS:** - GNU Bash (minimum recommended version **5.0.17**) ## Clone repository Clone GitHub repository to create a local copy on your computer to make -it easier to develop and test. Cloning of repository can be done by following +it easier to develop and test. Cloning of the repository can be done by following the below git command: ```bash @@ -55,27 +57,56 @@ git clone git@github.com:ARM-software/CMSIS-View.git ## Build components -The commands below demonstrate how to build and create executable: +The steps below demonstrate how to build and create an executable: + +- Go to eventlist directory + - cd \<**root**\>/tools/eventlist +- Run the command to build an executable under `build` directory + - `./make.sh build` : Build and generate executable for host OS & architecture in current directory. + - `./make.sh build -arch -os -outdir ` : Build and generate executable for provided configs.\ + for e.g. - - Go to eventlist directory - > cd \<**root**\>/tools/eventlist - - Create and switch to build directory ```bash - mkdir build - cd build + ./make.sh build -arch amd64 -os darwin -outdir "Path/to/output/dir" ``` - - Run go command to build an executable - > go build ./.. ## Run Tests -One can directly run the tests from command line. - - Go to eventlist directory +One can directly run the tests from the command line. + +- Go to eventlist directory + - cd \<**root**\>/tools/eventlist +- Clean existing cache test results + - go clean -cache +- Run command + - `./make.sh test` : Run all tests. + - `./make.sh test ` : Run test related to the specified package.\ + for e.g. + + ```bash + ./make.sh test eventlist/pkg/event + ``` + +## Code coverage + +Users can get coverage and generate code coverage report in HTML format + +- Go to eventlist directory > cd \<**root**\>/tools/eventlist - - Clean existing cache test results - > go clean -cache - - Run the executable - > go test ./... +- Run command + - `./make.sh coverage` : Run tests and show coverage info.\ + - `./make.sh coverage -html ` : Run tests with coverage info and generate specified HTML coverage report.\ + + for e.g. + + ```bash + ./make.sh coverage -html cov/coverage.html + ``` + +```txt +☑️ Note: + for more usable commands, Use `./make.sh -h`. +``` ## License diff --git a/tools/eventlist/main.go b/tools/eventlist/cmd/eventlist/main.go similarity index 91% rename from tools/eventlist/main.go rename to tools/eventlist/cmd/eventlist/main.go index 1924f80..c9dee58 100644 --- a/tools/eventlist/main.go +++ b/tools/eventlist/cmd/eventlist/main.go @@ -18,12 +18,10 @@ package main -//go:generate goversioninfo -gofile=versioninfo.go -arm=true - import ( - "eventlist/elf" - "eventlist/output" - "eventlist/xml/scvd" + "eventlist/pkg/elf" + "eventlist/pkg/output" + "eventlist/pkg/xml/scvd" "flag" "fmt" "os" @@ -31,6 +29,7 @@ import ( ) var Progname string +var versionInfo string type includes []string @@ -139,13 +138,7 @@ func main() { } if showVersion { - version := versionInfo.StringFileInfo.ProductVersion - i := strings.LastIndex(version, ".") - if i > 0 { - version = version[:i] - } - fmt.Printf("%s: Version %s\n", Progname, version) - fmt.Printf("%s\n", versionInfo.StringFileInfo.LegalCopyright) + fmt.Printf("%s %s\n", Progname, versionInfo) return } diff --git a/tools/eventlist/main_test.go b/tools/eventlist/cmd/eventlist/main_test.go similarity index 81% rename from tools/eventlist/main_test.go rename to tools/eventlist/cmd/eventlist/main_test.go index 952d528..a9d7b56 100644 --- a/tools/eventlist/main_test.go +++ b/tools/eventlist/cmd/eventlist/main_test.go @@ -164,28 +164,29 @@ func Test_main(t *testing.T) { //nolint:golint,paralleltest "\\t-s --statistic\\tshow statistic only\\n" + "\\t-V --version\\tshow version info\\n" + versionInfo = "1.2.3 (C) 2022 Arm Ltd. and Contributors" tests := []struct { name string args []string want string removefile string }{ - {"-a", []string{"-a", "testdata/nix", "xxx"}, ".*: open testdata/nix: (no such file or directory|The system cannot find the file specified.)\\n", ""}, - {"-s stdout", []string{"-s", "testdata/test10.binary"}, lines2, ""}, - {"-s", []string{"-s", "-o", outFile, "testdata/test10.binary"}, "\\[.*\\]\\n", outFile}, - {"-statistic", []string{"-statistic", "-o", outFile, "testdata/test10.binary"}, "\\[.*\\]\\n", outFile}, + {"-a", []string{"-a", "../../testdata/nix", "xxx"}, ".*: open ../../testdata/nix: (no such file or directory|The system cannot find the file specified.)\\n", ""}, + {"-s stdout", []string{"-s", "../../testdata/test10.binary"}, lines2, ""}, + {"-s", []string{"-s", "-o", outFile, "../../testdata/test10.binary"}, "\\[.*\\]\\n", outFile}, + {"-statistic", []string{"-statistic", "-o", outFile, "../../testdata/test10.binary"}, "\\[.*\\]\\n", outFile}, {"-help", []string{"-help"}, help, ""}, - {"stdout", []string{"testdata/test10.binary"}, lines1, ""}, - {"-o -begin", []string{"-begin", "-o", outFile, "testdata/test10.binary"}, "\\[.*\\]\\n", outFile}, - {"-o -b", []string{"-b", "-o", outFile, "testdata/test10.binary"}, "\\[.*\\]\\n", outFile}, - {"-o", []string{"-o", outFile, "testdata/test10.binary"}, "\\[.*\\]\\n", outFile}, - {"-o", []string{"-o", outFile, "testdata/nix"}, ".*: cannot open event file\\n", outFile}, - {"-V", []string{"-V"}, ".*: Version [0-9]+\\.[0-9]+\\.[0-9]+\\nCopyright \\(C\\) [0-9]+ ARM Limited or its Affiliates\\. All rights reserved\\.\\n", ""}, - {"-version", []string{"-version"}, ".*: Version [0-9]+\\.[0-9]+\\.[0-9]+\\nCopyright \\(C\\) [0-9]+ ARM Limited or its Affiliates\\. All rights reserved\\.\\n", ""}, + {"stdout", []string{"../../testdata/test10.binary"}, lines1, ""}, + {"-o -begin", []string{"-begin", "-o", outFile, "../../testdata/test10.binary"}, "\\[.*\\]\\n", outFile}, + {"-o -b", []string{"-b", "-o", outFile, "../../testdata/test10.binary"}, "\\[.*\\]\\n", outFile}, + {"-o", []string{"-o", outFile, "../../testdata/test10.binary"}, "\\[.*\\]\\n", outFile}, + {"-o", []string{"-o", outFile, "../../testdata/nix"}, ".*: cannot open event file\\n", outFile}, + {"-V", []string{"-V"}, ".* [0-9]+\\.[0-9]+\\.[0-9]+ \\(C\\) [0-9]+ Arm Ltd. and Contributors\\n", ""}, + {"-version", []string{"-version"}, ".* [0-9]+\\.[0-9]+\\.[0-9]+ \\(C\\) [0-9]+ Arm Ltd. and Contributors\\n", ""}, {"err", []string{"xxx", "yyy"}, ".*: only one binary input file allowed\n", ""}, {"missing", nil, ".*: missing input file\n", ""}, // -I must be the last test - {"-I", []string{"-I", "testdata/nix", "xxx"}, ".*: open testdata/nix: (no such file or directory|The system cannot find the file specified.)\\n", ""}, + {"-I", []string{"-I", "../../testdata/nix", "xxx"}, ".*: open ../../testdata/nix: (no such file or directory|The system cannot find the file specified.)\\n", ""}, } savedArgs := os.Args for _, tt := range tests { //nolint:golint,paralleltest diff --git a/tools/eventlist/cmd/make/make.go b/tools/eventlist/cmd/make/make.go new file mode 100644 index 0000000..080355b --- /dev/null +++ b/tools/eventlist/cmd/make/make.go @@ -0,0 +1,348 @@ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "bytes" + "errors" + "flag" + "fmt" + "os" + "os/exec" + "path" + "runtime" + "strconv" + "strings" + + "github.com/josephspurrier/goversioninfo" +) + +const program = "eventlist" +const mainPath = "./cmd/" + program +const resourceFileName = "resource.syso" +const unknownVersion = "0.0.0.0" + +var legalCopyright = " (C) 2022 Arm Ltd. and Contributors" + +// Errors +var ErrGitTag = errors.New("git tag error") +var ErrVersion = errors.New("version error") +var ErrCommand = errors.New("command error") + +func reportError(err error, msg string) error { + return fmt.Errorf("%w: %s", err, msg) +} + +type Options struct { + targetOs string + targetArch string + outDir string + covReport string +} + +type runner struct { + options Options + args []string +} + +func (r runner) run(command string) { + switch { + case command == "build": + versionStr, err := createResourceInfoFile(r.options.targetArch) + if err != nil { + fmt.Println(err.Error()) + return + } + versionInfo := versionStr + legalCopyright + if err = r.build(r.options, versionInfo); err != nil { + fmt.Println(err.Error()) + } + case command == "test": + if err := r.test(); err != nil { + fmt.Println(err.Error()) + return + } + case command == "coverage": + if r.options.covReport == "" { + if err := r.coverage(); err != nil { + fmt.Println(err.Error()) + return + } + } else { + if err := r.coverageReport(r.options.covReport); err != nil { + fmt.Println(err.Error()) + return + } + } + case command == "lint": + r.lint() + case command == "format": + r.format() + } +} + +func (r runner) executeCommand(command string) (err error) { + var stdout, stderr bytes.Buffer + cmd := exec.Command("bash", "-c", command) + cmd.Stdout = &stdout + cmd.Stderr = &stderr + err = cmd.Run() + stdoutStr := stdout.String() + stderrStr := stderr.String() + if stdoutStr != "" { + fmt.Println(stdoutStr) + } + if stderrStr != "" { + fmt.Println(stderrStr) + } + return err +} + +func (r runner) build(options Options, versionInfo string) (err error) { + var extn string + + if options.targetOs == "windows" { + extn = ".exe" + } + cmd := "GOOS=" + options.targetOs + " GOARCH=" + options.targetArch + + " go build -ldflags '-X \"main.versionInfo=" + versionInfo + + "\"' -o " + options.outDir + "/" + program + extn + " " + mainPath + + if err = r.executeCommand(cmd); err == nil { + fmt.Println("build finished successfully!") + } + return err +} + +func (r runner) test() (err error) { + args := "./..." + if len(r.args) != 0 { + args = strings.Join(r.args[:], " ") + } + return r.executeCommand("go test " + args) +} + +func (r runner) coverage() (err error) { + args := "./..." + if len(r.args) != 0 { + args = strings.Join(r.args[:], " ") + } + return r.executeCommand("go test -cover " + args) +} + +func (r runner) coverageReport(covReport string) (err error) { + covDir := path.Dir(covReport) + if covReport == covDir { + return reportError(ErrCommand, "invalid file path '"+covReport+"'") + } + + if _, err = os.Stat(covDir); os.IsNotExist(err) { + if err = os.Mkdir(covDir, os.ModePerm); err != nil { + return + } + } + err = r.executeCommand("go test ./... -coverprofile " + covDir + "/cover.out") + if err != nil { + return + } + err = r.executeCommand("go tool cover -html=" + covDir + "/cover.out -o " + covReport) + if err == nil { + fmt.Println("info: HTML coverage output written to " + covReport) + } + return +} + +func (r runner) lint() { + _ = r.executeCommand("golangci-lint run --config=./.golangci.yaml") +} + +func (r runner) format() { + _ = r.executeCommand("gofmt -s -w .") +} + +func fetchVersionInfoFromGit() (version version, err error) { + out, err := exec.Command("git", "describe", "--tags", "--match", "tools/eventlist/*").Output() + if len(out) == 0 && err != nil { + fmt.Println("warning: no release tag found, setting version to default \"0.0.0.0\"") + return newVersion(unknownVersion) + } + if err != nil { + return + } + tag := strings.TrimSpace(string(out)) + if tag == "" { + return version, reportError(ErrGitTag, "no git release tag found") + } + tokens := strings.Split(tag, "/") + if len(tokens) != 3 { + return version, reportError(ErrGitTag, "invalid release tag") + } + return newVersion(tokens[2]) +} + +func createResourceInfoFile(arch string) (version string, err error) { + gitVersion, err := fetchVersionInfoFromGit() + if err != nil { + return + } + + verInfo := goversioninfo.VersionInfo{} + + verInfo.FixedFileInfo.FileVersion = goversioninfo.FileVersion{ + Major: gitVersion.major, + Minor: gitVersion.minor, + Patch: gitVersion.patch, + Build: gitVersion.numCommit, + } + + verInfo.FixedFileInfo.ProductVersion = verInfo.FixedFileInfo.FileVersion + verInfo.StringFileInfo = goversioninfo.StringFileInfo{ + FileDescription: program, + InternalName: program, + ProductName: program, + OriginalFilename: program + ".exe", + FileVersion: gitVersion.String(), + ProductVersion: gitVersion.String(), + LegalCopyright: "Copyright" + legalCopyright, + } + verInfo.VarFileInfo.Translation = goversioninfo.Translation{ + LangID: 1033, + CharsetID: 1200, + } + + // Fill the structures with config data + verInfo.Build() + // Write the data to a buffer + verInfo.Walk() + + return verInfo.StringFileInfo.FileVersion, + verInfo.WriteSyso(mainPath+"/"+resourceFileName, arch) +} + +func isCommandValid(command string) (result bool) { + for _, cmd := range []string{ + "build", "coverage", "coverage-report", + "format", "help", "lint", "test", + } { + if cmd == command { + return true + } + } + fmt.Println(reportError(ErrCommand, "invalid command").Error()) + return false +} + +type version struct { + major, minor, patch int + numCommit int + shaCommit string +} + +func (v version) String() string { + if v.Empty() { + return unknownVersion + } + if v.shaCommit == "" && v.numCommit == 0 { + return fmt.Sprintf("%d.%d.%d.%d", v.major, v.minor, v.patch, v.numCommit) + } + return fmt.Sprintf("%d.%d.%d-dev%d+%s", v.major, v.minor, v.patch, v.numCommit, v.shaCommit) +} + +func (v version) Empty() bool { + if v.major == 0 && v.minor == 0 && v.patch == 0 && v.shaCommit == "" && v.numCommit == 0 { + return true + } + return false +} + +func newVersion(verStr string) (ver version, err error) { + if verStr == "" || verStr == unknownVersion { + return + } + + versionStr := strings.TrimSpace(verStr) + tokens := strings.Split(versionStr, "-") + numTokens := len(tokens) + + if !(numTokens == 1 || numTokens == 3) { + return ver, reportError(ErrVersion, "invalid version string") + } + verParts := strings.Split(tokens[0], ".") + if len(verParts) != 3 { + return ver, reportError(ErrVersion, "invalid version string") + } + + // Major + ver.major, err = strconv.Atoi(verParts[0]) + if err != nil { + return version{}, err + } + // Minor + ver.minor, err = strconv.Atoi(verParts[1]) + if err != nil { + return version{}, err + } + // Patch + ver.patch, err = strconv.Atoi(verParts[2]) + if err != nil { + return version{}, err + } + + if numTokens == 3 { + // Number of commits + ver.numCommit, err = strconv.Atoi(tokens[1]) + if err != nil { + return version{}, err + } + // SHA of commit + ver.shaCommit = tokens[2] + } + return ver, nil +} + +func main() { + if len(os.Args) < 2 { + fmt.Println(reportError(ErrCommand, "invalid command").Error()) + os.Exit(1) + } + + command := os.Args[1] + if !isCommandValid(command) { + os.Exit(1) + } + + commFlag := flag.CommandLine + targetOs := commFlag.String("os", runtime.GOOS, "Target Operating System") + targetArch := commFlag.String("arch", runtime.GOARCH, "Target architecture") + outDir := commFlag.String("outdir", ".", "Output directory") + covReport := commFlag.String("html", "", "Coverage report") + _ = commFlag.Parse(os.Args[2:]) + arguments := commFlag.Args() + + runner := runner{ + options: Options{ + targetOs: *targetOs, + targetArch: *targetArch, + outDir: *outDir, + covReport: *covReport, + }, + args: arguments, + } + runner.run(command) +} diff --git a/tools/eventlist/make.sh b/tools/eventlist/make.sh new file mode 100644 index 0000000..c3426ce --- /dev/null +++ b/tools/eventlist/make.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# ------------------------------------------------------- +# Copyright (c) 2022 Arm Limited. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 +# ------------------------------------------------------- + +# usage +usage() { + echo "" + echo "Usage:" + echo " make.sh [OPTIONS...]" + echo "" + echo "commands:" + echo " build : Build executable" + echo " coverage : Run tests with coverage info" + echo " format : Align indentation and format code" + echo " lint : Run linter" + echo " test : Run all tests" + echo "" + echo "build options:" + echo " -arch arg : Optional target architecture for e.g amd64 etc [default: host arch]" + echo " -os arg : Optional target operating system for e.g windows, linux, darwin etc [default: host OS]" + echo " -outdir arg : Optional output directory for executable generation [default: current directory]" + echo "" + echo "coverage options:" + echo " -html arg : Coverage file path" +} + +if [ $# -eq 0 ] +then + usage + exit 0 +fi + +for cmdline in "$@" +do + if [[ "${cmdline}" == "help" || "${cmdline}" == "-h" || "${cmdline}" == "--help" ]]; then + usage + exit 0 + fi + arg="${cmdline}" + args+=("${arg}") +done + +go run cmd/make/make.go "${args[@]}" + +RESULT=$? +if [ $RESULT -ne 0 ]; then + usage + exit 1 +fi +exit 0 \ No newline at end of file diff --git a/tools/eventlist/elf/elf.go b/tools/eventlist/pkg/elf/elf.go similarity index 100% rename from tools/eventlist/elf/elf.go rename to tools/eventlist/pkg/elf/elf.go diff --git a/tools/eventlist/elf/elf_test.go b/tools/eventlist/pkg/elf/elf_test.go similarity index 97% rename from tools/eventlist/elf/elf_test.go rename to tools/eventlist/pkg/elf/elf_test.go index 4e23965..321cb1f 100644 --- a/tools/eventlist/elf/elf_test.go +++ b/tools/eventlist/pkg/elf/elf_test.go @@ -24,9 +24,9 @@ import ( ) func Test_sections_Readelf(t *testing.T) { //nolint:golint,paralleltest - fileTest := "../testdata/elftest.elf" - fileNix := "../testdata/nix.elf" - fileSym := "../testdata/elfsym.elf" + fileTest := "../../testdata/elftest.elf" + fileNix := "../../testdata/nix.elf" + fileSym := "../../testdata/elfsym.elf" type args struct { name *string diff --git a/tools/eventlist/eval/eval.go b/tools/eventlist/pkg/eval/eval.go similarity index 100% rename from tools/eventlist/eval/eval.go rename to tools/eventlist/pkg/eval/eval.go diff --git a/tools/eventlist/eval/eval_test.go b/tools/eventlist/pkg/eval/eval_test.go similarity index 100% rename from tools/eventlist/eval/eval_test.go rename to tools/eventlist/pkg/eval/eval_test.go diff --git a/tools/eventlist/eval/expression.go b/tools/eventlist/pkg/eval/expression.go similarity index 100% rename from tools/eventlist/eval/expression.go rename to tools/eventlist/pkg/eval/expression.go diff --git a/tools/eventlist/eval/expression_test.go b/tools/eventlist/pkg/eval/expression_test.go similarity index 100% rename from tools/eventlist/eval/expression_test.go rename to tools/eventlist/pkg/eval/expression_test.go diff --git a/tools/eventlist/eval/value.go b/tools/eventlist/pkg/eval/value.go similarity index 99% rename from tools/eventlist/eval/value.go rename to tools/eventlist/pkg/eval/value.go index 76c5cc1..e9cf891 100644 --- a/tools/eventlist/eval/value.go +++ b/tools/eventlist/pkg/eval/value.go @@ -18,7 +18,7 @@ package eval -import "eventlist/elf" +import "eventlist/pkg/elf" type Value struct { t Token diff --git a/tools/eventlist/eval/value_test.go b/tools/eventlist/pkg/eval/value_test.go similarity index 99% rename from tools/eventlist/eval/value_test.go rename to tools/eventlist/pkg/eval/value_test.go index e0a20d6..7049239 100644 --- a/tools/eventlist/eval/value_test.go +++ b/tools/eventlist/pkg/eval/value_test.go @@ -19,7 +19,7 @@ package eval import ( - "eventlist/elf" + "eventlist/pkg/elf" "reflect" "testing" ) diff --git a/tools/eventlist/eval/variable.go b/tools/eventlist/pkg/eval/variable.go similarity index 100% rename from tools/eventlist/eval/variable.go rename to tools/eventlist/pkg/eval/variable.go diff --git a/tools/eventlist/eval/variable_test.go b/tools/eventlist/pkg/eval/variable_test.go similarity index 100% rename from tools/eventlist/eval/variable_test.go rename to tools/eventlist/pkg/eval/variable_test.go diff --git a/tools/eventlist/event/event.go b/tools/eventlist/pkg/event/event.go similarity index 99% rename from tools/eventlist/event/event.go rename to tools/eventlist/pkg/event/event.go index 8765519..2acc172 100644 --- a/tools/eventlist/event/event.go +++ b/tools/eventlist/pkg/event/event.go @@ -22,9 +22,9 @@ import ( "bufio" "encoding/binary" "errors" - "eventlist/elf" - "eventlist/eval" - "eventlist/xml/scvd" + "eventlist/pkg/elf" + "eventlist/pkg/eval" + "eventlist/pkg/xml/scvd" "fmt" "io" "os" diff --git a/tools/eventlist/event/event_test.go b/tools/eventlist/pkg/event/event_test.go similarity index 97% rename from tools/eventlist/event/event_test.go rename to tools/eventlist/pkg/event/event_test.go index f97656d..3add463 100644 --- a/tools/eventlist/event/event_test.go +++ b/tools/eventlist/pkg/event/event_test.go @@ -21,9 +21,9 @@ package event import ( "bufio" "errors" - "eventlist/elf" - "eventlist/eval" - "eventlist/xml/scvd" + "eventlist/pkg/elf" + "eventlist/pkg/eval" + "eventlist/pkg/xml/scvd" "reflect" "testing" ) @@ -169,7 +169,7 @@ func TestInfo_SplitID(t *testing.T) { func TestEventData_calculateExpression(t *testing.T) { //nolint:golint,paralleltest var i int - fileTest := "../testdata/elftest.elf" + fileTest := "../../testdata/elftest.elf" type fields struct { Time uint64 @@ -517,13 +517,13 @@ func Test_convert64(t *testing.T) { func TestEventData_Read(t *testing.T) { t.Parallel() - var s0 = "../testdata/test0.binary" - var s1 = "../testdata/test1.binary" - var s2 = "../testdata/test2.binary" - var sNix = "../testdata/xxxx" - var s3 = "../testdata/test3.binary" - var s4 = "../testdata/test4.binary" - var s5 = "../testdata/test5.binary" + var s0 = "../../testdata/test0.binary" + var s1 = "../../testdata/test1.binary" + var s2 = "../../testdata/test2.binary" + var sNix = "../../testdata/xxxx" + var s3 = "../../testdata/test3.binary" + var s4 = "../../testdata/test4.binary" + var s5 = "../../testdata/test5.binary" var b0 = []uint8("hello wo") diff --git a/tools/eventlist/output/output.go b/tools/eventlist/pkg/output/output.go similarity index 99% rename from tools/eventlist/output/output.go rename to tools/eventlist/pkg/output/output.go index b85ab5f..2f2ed05 100644 --- a/tools/eventlist/output/output.go +++ b/tools/eventlist/pkg/output/output.go @@ -21,9 +21,9 @@ package output import ( "bufio" "errors" - "eventlist/eval" - "eventlist/event" - "eventlist/xml/scvd" + "eventlist/pkg/eval" + "eventlist/pkg/event" + "eventlist/pkg/xml/scvd" "fmt" "math" "os" diff --git a/tools/eventlist/output/output_test.go b/tools/eventlist/pkg/output/output_test.go similarity index 97% rename from tools/eventlist/output/output_test.go rename to tools/eventlist/pkg/output/output_test.go index 5288a92..0cbb850 100644 --- a/tools/eventlist/output/output_test.go +++ b/tools/eventlist/pkg/output/output_test.go @@ -22,8 +22,8 @@ import ( "bufio" "bytes" "errors" - "eventlist/event" - "eventlist/xml/scvd" + "eventlist/pkg/event" + "eventlist/pkg/xml/scvd" "fmt" "io" "math" @@ -609,11 +609,11 @@ func TestOutput_buildStatistic(t *testing.T) { //nolint:golint,paralleltest tds := make(map[string]map[string]map[int16]string) - var s1 = "../testdata/test1.binary" - var s3 = "../testdata/test3.binary" - var s4 = "../testdata/test4.binary" - var s6 = "../testdata/test6.binary" - var s7 = "../testdata/test7.binary" + var s1 = "../../testdata/test1.binary" + var s3 = "../../testdata/test3.binary" + var s4 = "../../testdata/test4.binary" + var s6 = "../../testdata/test6.binary" + var s7 = "../../testdata/test7.binary" type fields struct { evProps [4]eventProperty @@ -766,11 +766,11 @@ func TestOutput_printEvents(t *testing.T) { //nolint:golint,paralleltest eds[0xFE00] = scvd.Event{Brief: "briefbriefbrief", Property: "propertypropertyproperty", Value: "value"} eds[0xFF03] = scvd.Event{Brief: "briefbriefbrief", Property: "propertypropertyproperty", Value: "value"} - var s0 = "../testdata/test0.binary" - var s1 = "../testdata/test1.binary" - var s10 = "../testdata/test10.binary" - var s11 = "../testdata/test11.binary" - var sNix = "../testdata/xxxx" + var s0 = "../../testdata/test0.binary" + var s1 = "../../testdata/test1.binary" + var s10 = "../../testdata/test10.binary" + var s11 = "../../testdata/test11.binary" + var sNix = "../../testdata/xxxx" line1 := " 0 0.00000124 0xFF 0xFF03 val1=0x00000004, val2=0x00000002\n" + " 1 0.00000124 0xFE 0xFE00 \"hello wo\"\n" @@ -900,9 +900,9 @@ func TestOutput_printHeader(t *testing.T) { //nolint:golint,paralleltest func TestOutput_print(t *testing.T) { //nolint:golint,paralleltest var b bytes.Buffer - // var e0 = "../testdata/test.xml" - var s10 = "../testdata/test10.binary" - var s11 = "../testdata/nix.binary" + // var e0 = "../../testdata/test.xml" + var s10 = "../../testdata/test10.binary" + var s11 = "../../testdata/nix.binary" line1 := " Detailed event list\n" + " -------------------\n\n" + @@ -981,7 +981,7 @@ func TestOutput_print(t *testing.T) { //nolint:golint,paralleltest func TestPrint(t *testing.T) { //nolint:golint,paralleltest o1 := "testOutput.out" - var s10 = "../testdata/test10.binary" + var s10 = "../../testdata/test10.binary" lines1 := [...]string{ " Detailed event list\n", diff --git a/tools/eventlist/xml/scvd/scvd.go b/tools/eventlist/pkg/xml/scvd/scvd.go similarity index 99% rename from tools/eventlist/xml/scvd/scvd.go rename to tools/eventlist/pkg/xml/scvd/scvd.go index 2097cb6..0a049f2 100644 --- a/tools/eventlist/xml/scvd/scvd.go +++ b/tools/eventlist/pkg/xml/scvd/scvd.go @@ -21,7 +21,7 @@ package scvd import ( "encoding/xml" "errors" - "eventlist/eval" + "eventlist/pkg/eval" "os" "strconv" "strings" diff --git a/tools/eventlist/xml/scvd/scvd_test.go b/tools/eventlist/pkg/xml/scvd/scvd_test.go similarity index 91% rename from tools/eventlist/xml/scvd/scvd_test.go rename to tools/eventlist/pkg/xml/scvd/scvd_test.go index 2300e4f..e055301 100644 --- a/tools/eventlist/xml/scvd/scvd_test.go +++ b/tools/eventlist/pkg/xml/scvd/scvd_test.go @@ -24,8 +24,8 @@ import ( ) func TestComponentViewer_getFromFile(t *testing.T) { - var name = "../../testdata/test.xml" - var wrongName = "../../testdata/xxxxx" + var name = "../../../testdata/test.xml" + var wrongName = "../../../testdata/xxxxx" type fields struct { Component Component @@ -120,11 +120,11 @@ func TestID_getIdValue(t *testing.T) { } func Test_getOne(t *testing.T) { - var name = "../../testdata/test.xml" - var wrongName = "../../testdata/xxxxx" - var nameErr1 = "../../testdata/test_err1.xml" - var nameErr2 = "../../testdata/test_err2.xml" - var nameErr3 = "../../testdata/test_err3.xml" + var name = "../../../testdata/test.xml" + var wrongName = "../../../testdata/xxxxx" + var nameErr1 = "../../../testdata/test_err1.xml" + var nameErr2 = "../../../testdata/test_err2.xml" + var nameErr3 = "../../../testdata/test_err3.xml" var evs = make(map[uint16]Event) var tds = make(map[string]map[string]map[int16]string) @@ -166,8 +166,8 @@ func Test_getOne(t *testing.T) { } func TestGet(t *testing.T) { - var files = []string{"../../testdata/test.xml"} - var files1 = []string{"../../testdata/xxxxx"} + var files = []string{"../../../testdata/test.xml"} + var files1 = []string{"../../../testdata/xxxxx"} var evs = make(map[uint16]Event) var tds = make(map[string]map[string]map[int16]string) diff --git a/tools/eventlist/versioninfo.go b/tools/eventlist/versioninfo.go deleted file mode 100644 index feeb815..0000000 --- a/tools/eventlist/versioninfo.go +++ /dev/null @@ -1,56 +0,0 @@ -// Auto-generated file by goversioninfo. Do not edit. -package main - -import ( - "encoding/json" - - "github.com/josephspurrier/goversioninfo" -) - -func unmarshalGoVersionInfo(b []byte) goversioninfo.VersionInfo { - vi := goversioninfo.VersionInfo{} - json.Unmarshal(b, &vi) - return vi -} - -var versionInfo = unmarshalGoVersionInfo([]byte(`{ - "FixedFileInfo":{ - "FileVersion": { - "Major": 1, - "Minor": 0, - "Patch": 10, - "Build": 0 - }, - "ProductVersion": { - "Major": 1, - "Minor": 0, - "Patch": 10, - "Build": 0 - }, - "FileFlagsMask": "3f", - "FileFlags": "", - "FileOS": "040004", - "FileType": "01", - "FileSubType": "00" - }, - "StringFileInfo":{ - "Comments": "", - "CompanyName": "ARM Limited", - "FileDescription": "", - "FileVersion": "1.0.10.0", - "InternalName": "eventlist", - "LegalCopyright": "Copyright (C) 2022 ARM Limited or its Affiliates. All rights reserved.", - "LegalTrademarks": "", - "OriginalFilename": "eventlist", - "PrivateBuild": "", - "ProductName": "eventlist", - "ProductVersion": "1.0.10.0", - "SpecialBuild": "" - }, - "VarFileInfo":{ - "Translation": { - "LangID": 1033, - "CharsetID": 1200 - } - } -}`)) diff --git a/tools/eventlist/versioninfo.json b/tools/eventlist/versioninfo.json deleted file mode 100644 index 9542326..0000000 --- a/tools/eventlist/versioninfo.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "FixedFileInfo": { - "FileVersion": { - "Major": 1, - "Minor": 0, - "Patch": 10, - "Build": 0 - }, - "ProductVersion": { - "Major": 1, - "Minor": 0, - "Patch": 10, - "Build": 0 - }, - "FileFlagsMask": "3f", - "FileFlags ": "00", - "FileOS": "040004", - "FileType": "01", - "FileSubType": "00" - }, - "StringFileInfo": { - "Comments": "", - "CompanyName": "ARM Limited", - "FileDescription": "", - "FileVersion": "1.0.10.0", - "InternalName": "eventlist", - "LegalCopyright": "Copyright (C) 2022 ARM Limited or its Affiliates. All rights reserved.", - "LegalTrademarks": "", - "OriginalFilename": "eventlist", - "PrivateBuild": "", - "ProductName": "eventlist", - "ProductVersion": "1.0.10.0", - "SpecialBuild": "" - }, - "VarFileInfo": { - "Translation": { - "LangID": "0409", - "CharsetID": "04B0" - } - }, - "IconPath": "", - "ManifestPath": "" -}