Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 10 additions & 39 deletions .github/workflows/eventlist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ jobs:
startsWith(github.ref, 'refs/tags/tools/eventlist/')
strategy:
matrix:
os: [ubuntu-20.04]
config:
- { os: macos-12, target: darwin64 }
- { os: windows-2019, target: windows64 }
- { os: ubuntu-20.04, target: linux64 }
go: [1.17.x]
name: 'Build'
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.config.os }}
steps:
- name: Check out repository code
uses: actions/checkout@v2
Expand All @@ -41,22 +44,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 executable
run: |
GOOS=linux GOARCH=amd64 go build -o linux64/eventlist ./..
GOOS=darwin GOARCH=amd64 go build -o darwin64/eventlist ./..
GOOS=windows GOARCH=amd64 go build -o windows64/eventlist.exe ./..
working-directory: ./tools/eventlist/build
go run cmd/make/make.go build
working-directory: ./tools/eventlist

- name: Perform CodeQL Analysis
if: github.event_name != 'release'
Expand All @@ -65,24 +56,8 @@ jobs:
- name: Archive eventlist
uses: actions/upload-artifact@v2
with:
name: eventlist-linux64
path: ./tools/eventlist/build/linux64
retention-days: 1
if-no-files-found: error

- name: Archive eventlist
uses: actions/upload-artifact@v2
with:
name: eventlist-darwin64
path: ./tools/eventlist/build/darwin64
retention-days: 1
if-no-files-found: error

- name: Archive eventlist
uses: actions/upload-artifact@v2
with:
name: eventlist-windows64
path: ./tools/eventlist/build/windows64
name: eventlist-{{ matrix.config.target }}
path: ./tools/eventlist/build
retention-days: 1
if-no-files-found: error

Expand Down Expand Up @@ -228,13 +203,9 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: Create build folder
run: mkdir build
working-directory: ./tools/eventlist

- name: Check coverage
run: |
go test ./... -coverprofile build/cover.out
go run cmd/make/make.go coverage
test `go tool cover -func build/cover.out | tail -1 | awk '{print ($3 + 0)*10}'` -gt 980
working-directory: ./tools/eventlist

Expand Down
11 changes: 3 additions & 8 deletions tools/eventlist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,8 @@ The commands below demonstrate how to build and create executable:

- Go to root directory
> cd \<**root**\>
- Create and switch to build directory
```bash
mkdir build
cd build
```
- Run go command to build an executable
> go build ./..
- Run go command to build an executable under **\<root\>/build** directory
> go run cmd/make/make.go build

## Run Tests

Expand All @@ -75,7 +70,7 @@ One can directly run the tests from command line.
- Clean existing cache test results
> go clean -cache
- Run the executable
> go test ./...
> go run cmd/make/make.go test

## License

Expand Down
22 changes: 11 additions & 11 deletions tools/eventlist/main.go → tools/eventlist/cmd/eventlist/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@

package main

//go:generate goversioninfo -gofile=versioninfo.go

import (
"eventlist/elf"
"eventlist/output"
"eventlist/xml/scvd"
"eventlist/pkg/elf"
"eventlist/pkg/output"
"eventlist/pkg/xml/scvd"
"flag"
"fmt"
"os"
"strings"
)

var Progname string
var versionInfo string

type includes []string

Expand Down Expand Up @@ -139,13 +138,14 @@ func main() {
}

if showVersion {
version := versionInfo.StringFileInfo.ProductVersion
i := strings.LastIndex(version, ".")
if i > 0 {
version = version[:i]
if versionInfo == "" {
versionInfo = "unknown"
}
info := strings.Split(versionInfo, "#")
fmt.Printf("%s: Version %s\n", Progname, info[0])
if len(info) > 1 {
fmt.Printf("%s\n", info[1])
}
fmt.Printf("%s: Version %s\n", Progname, version)
fmt.Printf("%s\n", versionInfo.StringFileInfo.LegalCopyright)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,28 +164,30 @@ 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#Copyright (C) 2022 ARM Limited or its Affiliates. All rights reserved."

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"}, ".*: 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", ""},
{"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
Expand Down
Loading