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
29 changes: 11 additions & 18 deletions .github/workflows/eventlist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
if: |
Expand Down Expand Up @@ -41,33 +45,22 @@ 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'
uses: github/codeql-action/analyze@v2

- 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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ __debug_bin
*.bak
*.syso
*.log
*.out
63 changes: 47 additions & 16 deletions tools/eventlist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <ARCH> -os <OS> -outdir <OUT directory>` : 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 <PACKAGE>` : 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 <FILE path>` : 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

Expand Down
17 changes: 5 additions & 12 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 -arm=true

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,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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading