-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sha3_only_rename
- Loading branch information
Showing
12 changed files
with
35,022 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
set -euxo pipefail | ||
|
||
source tests/ci/common_posix_setup.sh | ||
|
||
# For now we will just verify that the patch applies and our reporting to builds and tests successfully | ||
# Subsequent follow-up PRs will wire this up into a new CodeBuild project and handle producing and tracking | ||
# the reports. | ||
|
||
SCRATCH_DIR="${SYS_ROOT}/scratch" | ||
X509_CI_DIR="${SRC_ROOT}/tests/ci/x509" | ||
X509_LIMBO_SRC="${SCRATCH_DIR}/x509-limbo" | ||
|
||
function build_reporting_tool() { | ||
pushd "${X509_CI_DIR}/limbo-report" | ||
make | ||
mv ./limbo-report "${SCRATCH_DIR}/" | ||
popd # "${X509_CI_DIR}/limbo-report" | ||
} | ||
|
||
function clone_and_patch_x509_limbo() { | ||
git clone https://github.com/C2SP/x509-limbo.git "${X509_LIMBO_SRC}" | ||
pushd "${X509_LIMBO_SRC}" | ||
patch -p1 -i "${X509_CI_DIR}/x509-limbo.patch" | ||
popd # "${X509_LIMBO_SRC}" | ||
} | ||
|
||
function run_aws_lc_harness() { | ||
pushd "${X509_LIMBO_SRC}" | ||
AWS_LC_SRC_DIR="${SRC_ROOT}" make test-aws-lc | ||
popd # "${X509_LIMBO_SRC}" | ||
} | ||
|
||
mkdir -p "${SCRATCH_DIR}" | ||
rm -rf "${SCRATCH_DIR:?}"/* | ||
pushd "${SCRATCH_DIR}" | ||
|
||
build_reporting_tool | ||
clone_and_patch_x509_limbo | ||
run_aws_lc_harness | ||
|
||
popd # "${SCRATCH_DIR}" | ||
# rm -rf "${SCRATCH_DIR:?}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
limbo-report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.PHONY: all build test fmt vet | ||
|
||
all: build vet test | ||
|
||
build: | ||
go build ./... | ||
|
||
test: | ||
go test ./... | ||
|
||
fmt: | ||
go fmt ./... | ||
|
||
vet: | ||
go vet ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR ISC | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/csv" | ||
"encoding/json" | ||
"flag" | ||
"fmt" | ||
"io" | ||
"log" | ||
"os" | ||
"sort" | ||
) | ||
|
||
var annotateHelpDoc string = `report annotate [-csv] <limboFile> <resultFile> | ||
Annotates a standard x509-limbo results file with information from the provided <limboFile> test descriptors. | ||
By default this will write the result back to the process standard output. | ||
Options: | ||
-csv Write the results to standard output in csv format rather then the default json format | ||
` | ||
|
||
var annotateCommand struct { | ||
formatAsCsv bool | ||
} | ||
|
||
var annotateFlagSet = func() *flag.FlagSet { | ||
fs := flag.NewFlagSet("annotate", flag.ExitOnError) | ||
fs.BoolVar(&annotateCommand.formatAsCsv, "csv", false, "format output as csv rather then the default") | ||
fs.Usage = func() { | ||
fmt.Fprint(fs.Output(), annotateHelpDoc) | ||
} | ||
|
||
return fs | ||
}() | ||
|
||
func runAnnotateCommand(args []string) error { | ||
if err := annotateFlagSet.Parse(args); err != nil { | ||
return err | ||
} | ||
|
||
if len(annotateFlagSet.Args()) != 2 { | ||
return fmt.Errorf("expect two positional arguments") | ||
} | ||
|
||
limbo, err := parseLimboFile(annotateFlagSet.Arg(0)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
harnessFilePath := annotateFlagSet.Arg(1) | ||
harnessBytes, err := os.ReadFile(harnessFilePath) | ||
if err != nil { | ||
log.Fatalf("failed to read harnessFile(%v): %v", harnessFilePath, err) | ||
} | ||
|
||
var hr HarnessResults | ||
if err := json.Unmarshal(harnessBytes, &hr); err != nil { | ||
log.Fatalf("failed to parse json: %v", err) | ||
} | ||
if err := hr.Annotate(limbo); err != nil { | ||
return err | ||
} | ||
|
||
if annotateCommand.formatAsCsv { | ||
return writeCsvJudgementReport(&hr, os.Stdout) | ||
} | ||
|
||
return writeJsonJudgementReport(&hr, os.Stdout) | ||
} | ||
|
||
func parseLimboFile(filePath string) (limbo *Limbo, err error) { | ||
testCasesBytes, err := os.ReadFile(filePath) | ||
if err != nil { | ||
return limbo, fmt.Errorf("failed to read limbo test cases: %w", err) | ||
} | ||
|
||
var unmarshaled Limbo | ||
|
||
if err := json.Unmarshal(testCasesBytes, &unmarshaled); err != nil { | ||
return limbo, fmt.Errorf("failed to parse json: %w", err) | ||
} | ||
|
||
limbo = &unmarshaled | ||
|
||
return limbo, nil | ||
} | ||
|
||
func writeJsonJudgementReport(hr *HarnessResults, out io.Writer) error { | ||
jsonWriter := json.NewEncoder(out) | ||
jsonWriter.SetIndent("", " ") | ||
|
||
if err := jsonWriter.Encode(hr); err != nil { | ||
return fmt.Errorf("failed to encode harness judgement: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func writeCsvJudgementReport(hr *HarnessResults, out io.Writer) error { | ||
csvWriter := csv.NewWriter(out) | ||
defer csvWriter.Flush() | ||
|
||
csvWriter.Write([]string{"id", "expected", "result", "judgement", "context"}) | ||
|
||
// Normalize The Report for Diffing | ||
var sortedIds []string | ||
for id := range hr.Results { | ||
sortedIds = append(sortedIds, id) | ||
} | ||
sort.Strings(sortedIds) | ||
|
||
for _, id := range sortedIds { | ||
tr := hr.Results[id] | ||
csvWriter.Write([]string{id, string(tr.ExpectedResult), string(tr.ActualResult), string(tr.Judgement), tr.Context}) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.