Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jlog: add group and file cat to logs #22

Merged
merged 5 commits into from
Oct 1, 2024
Merged
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
14 changes: 9 additions & 5 deletions .github/workflows/amd64-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: check safety
run: make -j$JOBS -C src/ CI=1 check-safety
- name: print report
run: make -C src/ CI=1 reporter
run: make -C src/ CI=1 reporter-check-safety
- name: return error
run: make -C src/ CI=1 err

Expand All @@ -32,7 +32,7 @@ jobs:
- name: check speculative constant-time (v1)
run: make -j$JOBS -C src/ CI=1 check-sct
- name: print report
run: make -C src/ CI=1 reporter
run: make -C src/ CI=1 reporter-check-sct
- name: return error
run: make -C src/ CI=1 err

Expand All @@ -45,7 +45,7 @@ jobs:
- name: check extraction from Jasmin to EasyCrypt
run: make -j$JOBS -C src/ CI=1 extract-to-easycrypt
- name: print report
run: make -C src/ CI=1 reporter
run: make -C src/ CI=1 reporter-extract-to-easycrypt
- name: return error
run: make -C src/ CI=1 err

Expand All @@ -58,7 +58,7 @@ jobs:
- name: check compilation of libformosa25519.a
run: make -j$JOBS -C src/ CI=1 libformosa25519.a
- name: print report
run: make -C src/ CI=1 reporter
run: make -C src/ CI=1 reporter-compile
- name: return error
run: make -C src/ CI=1 err

Expand Down Expand Up @@ -92,6 +92,10 @@ jobs:
uses: actions/checkout@v4

- name: run proof
run: make -j$JOBS -C proof/
run: make -j$JOBS -C proof/ all-no-report
- name: print report
run: make -C proof/ CI=1 reporter
- name: return error
run: make -C proof/ CI=1 err


8 changes: 5 additions & 3 deletions bench/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CFLAGS ?= -Wall -Wno-unused-function -Wno-unused-parameter -O3 -march=native \

CI ?= 0
CI_REMOVE_OK_LOGS ?= "1"
CI_GITHUB?=0

CI_DIR = $(@D)
CI_CMD =
Expand All @@ -22,6 +23,7 @@ CI_CMD = 2> $(CI_DIR)/$(@F).log && rm -f $(CI_DIR)/$(@F).error || \
rm -f $(CI_DIR)/$(@F).log && \
exit 127 \
)
CI_GITHUB:=1
endif

export CI
Expand Down Expand Up @@ -155,9 +157,9 @@ CI_ALL_FILES := $(shell test -d $(BIN) && find $(BIN) -name '*.log') $(CI_ERRO
.PHONY: reporter logs $(LOGS) err

reporter:
$(JLOG) "Compilation status (*.jazz -> *.s)" src/ *.s $(CI_REMOVE_OK_LOGS)
$(JLOG) "Bench compilation status" bench/$(BIN) bench $(CI_REMOVE_OK_LOGS)
$(JLOG) "Bench execution status" bench/$(BIN) bench.out $(CI_REMOVE_OK_LOGS)
$(JLOG) "Compilation status (*.jazz -> *.s)" src/ *.s $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)
$(JLOG) "Bench compilation status" bench/$(BIN) bench $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)
$(JLOG) "Bench execution status" bench/$(BIN) bench.out $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)

logs: $(LOGS)

Expand Down
15 changes: 12 additions & 3 deletions proof/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ALL_OUT := $(addsuffix .out, $(ALL))

CI ?= 0
CI_REMOVE_OK_LOGS ?= "1"
CI_GITHUB?=0

CI_DIR =
CI_CMD =
Expand All @@ -35,6 +36,7 @@ CI_CMD = 2> $(@D)/$(CI_DIR)/$(@F).log && rm -f $(@D)/$(CI_DIR)/$(@F).error || \
rm $(@D)/$(CI_DIR)/$(@F).log && \
exit 0 \
)
CI_GITHUB:=1
endif

export CI
Expand Down Expand Up @@ -84,9 +86,9 @@ CI_ALL_FILES := $(shell find $(PROOF) -name '*.log') $(CI_ERROR_FILES)
.PHONY: reporter logs $(LOGS) err

reporter:
$(JLOG) "Extraction from Jasmin to EasyCrypt status" src/ *_s.ec $(CI_REMOVE_OK_LOGS)
$(JLOG) "Checking EasyCrypt - extracted files status" proof/ *_s.ec.out $(CI_REMOVE_OK_LOGS)
$(JLOG) "Checking EasyCrypt - all files status" proof/ *.ec.out $(CI_REMOVE_OK_LOGS)
$(JLOG) "Extraction from Jasmin to EasyCrypt status" src/ *_s.ec $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)
$(JLOG) "Checking EasyCrypt - extracted files status" proof/ *_s.ec.out $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)
$(JLOG) "Checking EasyCrypt - all files status" proof/ *.ec.out $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)

logs: $(LOGS)

Expand Down Expand Up @@ -118,6 +120,13 @@ all:
$(MAKE) reporter
$(MAKE) err

all-no-report: CI=1
all-no-report:
$(MAKE) distclean
$(MAKE) -C $(SRC) extract-to-easycrypt
$(MAKE) check-extracted
$(MAKE) check-all

# -----------------------------------------------------------------------------
# clean rules

Expand Down
64 changes: 51 additions & 13 deletions scripts/reporter/jlog
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ top=$(cd "$(dirname "$0")/../../" ; pwd -P)
dir=$top/$2
spattern=$3
rempty=$4
ghci=$5

NORMAL="\e[0m"
RESET="\e[0m"
BOLD="\e[1m"
RED="\e[31m"
GREEN="\e[32m"
Expand All @@ -29,16 +30,53 @@ status()
sort -t',' -g -k1 | sed -e 's/^[ \t]*//' -e 's/, \.\//, /' > $output
}

print()
# cat file in color
cat_c_file()
{
color=$1
file=$2

echo -e "${color}"
sed '/\r/d' $file | uniq | cat -
echo -e "${RESET}"
}

# print bold color - some string and a valid file name
print_bc()
{
prefix=$1
color=$2
string=$3
file_name=$4

file_name_relative=$(realpath --relative-to=$top $file_name)

echo -e "${prefix}${color}${string}${file_name_relative}${RESET}"
}

print_file()
{
color=$1;
filter=$2;
file=$3;
label=$4;

begin_group=""
end_group=""
if [[ $ghci -eq 1 ]]; then
begin_group="::group::"
end_group="::endgroup::"
fi

egrep -E "$filter" $file | \
while read line; do
echo -e "${color}${BOLD}${label}, ${line}${NORMAL}"
while IFS=',' read -r line_count file_name; do
if [[ "$line_count" != "0" ]]; then
print_bc "${begin_group}" "${color}" "${label}, ${line_count}, " "${file_name}"
if [[ $ghci -eq 1 ]]; then cat_c_file "${color}" "${file_name}"; fi
if [[ $ghci -eq 1 ]]; then echo "${end_group}"; fi
else
print_bc "" "${color}" "${label}, 0, " "${file_name}"
fi
done
}

Expand All @@ -51,22 +89,22 @@ clear_empty()
done
}

warning=$(mktemp)
error=$(mktemp)
okandwarnings=$(mktemp)
errors=$(mktemp)

status "${spattern}.log" $warning;
status "${spattern}.error" $error;
status "${spattern}.log" $okandwarnings;
status "${spattern}.error" $errors;

# print
echo -e "${BOLD}$message: ${NORMAL}"

print $GREEN "^0" $warning "OK";
print $YELLOW "^[^0]" $warning "WARNING";
print $RED "" $error "ERROR";
print_file $GREEN "^0" $okandwarnings "OK";
print_file $YELLOW "^[^0]" $okandwarnings "WARNING";
print_file $RED "" $errors "ERROR";

if [ "$rempty" == "1" ]; then
clear_empty $warning;
clear_empty $okandwarnings;
fi

rm $warning $error
rm $okandwarnings $errors

24 changes: 19 additions & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ C_HEADER_FILES ?= $(addsuffix include/api.h, $(dir $(ASSEMBLY_FILES)))
# of the current status: compilation, safety checking, and sct checking.
CI ?= 0
CI_REMOVE_OK_LOGS ?= "1"
CI_GITHUB?=0

ifeq ($(CI),1)
CI_GITHUB:=1
endif

export CI

Expand Down Expand Up @@ -141,12 +146,21 @@ CI_ERROR_FILES := $(shell find $(SRC) -name '*.error')
CI_ALL_FILES := $(shell find $(SRC) -name '*.log') $(CI_ERROR_FILES)

.PHONY: reporter logs $(LOGS) err
.PHONY: reporter-check-safety reporter-check-sct reporter-extract-to-easycrypt reporter-compile

reporter: reporter-check-safety reporter-check-sct reporter-extract-to-easycrypt reporter-compile

reporter-check-safety:
$(JLOG) "Safety checking status" src/ *.safety $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)

reporter-check-sct:
$(JLOG) "Speculative constant-time status" src/ *.sct $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)

reporter-extract-to-easycrypt:
$(JLOG) "Extraction to EasyCrypt status" src/ *.ec $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)

reporter:
$(JLOG) "Safety checking status" src/ *.safety $(CI_REMOVE_OK_LOGS)
$(JLOG) "Speculative constant-time status" src/ *.sct $(CI_REMOVE_OK_LOGS)
$(JLOG) "Extraction to EasyCrypt status" src/ *.ec $(CI_REMOVE_OK_LOGS)
$(JLOG) "Compilation status (*.jazz -> *.s)" src/ *.s $(CI_REMOVE_OK_LOGS)
reporter-compile:
$(JLOG) "Compilation status (*.jazz -> *.s)" src/ *.s $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)

logs: $(LOGS)

Expand Down
10 changes: 6 additions & 4 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CFLAGS ?= -O3 -Wall -Wextra -Wpedantic -Wvla -Werror -std=c99 \

CI ?= 0
CI_REMOVE_OK_LOGS ?= "1"
CI_GITHUB?=0

CI_DIR = $(@D)
CI_CMD =
Expand All @@ -20,6 +21,7 @@ CI_CMD = 2> $(CI_DIR)/$(@F).log && rm -f $(CI_DIR)/$(@F).error || \
rm -f $(CI_DIR)/$(@F).log && \
exit 127 \
)
CI_GITHUB:=1
endif

export CI
Expand Down Expand Up @@ -125,13 +127,13 @@ CI_ALL_FILES := $(shell test -d $(BIN) && find $(BIN) -name '*.log') $(CI_ERRO
.PHONY: reporter logs $(LOGS) err

reporter:
$(JLOG) "Compilation status (*.jazz -> *.s)" src/ *.s $(CI_REMOVE_OK_LOGS)
$(JLOG) "Compilation status (*.jazz -> *.s)" src/ *.s $(CI_REMOVE_OK_LOGS) $(CI_GITHUB)
@for type in $(TESTS_NAMES); do \
$(JLOG) "Tests compilation status - $$type" test/$(BIN) $$type $(CI_REMOVE_OK_LOGS); \
$(JLOG) "Tests execution status - $$type" test/$(BIN) $$type.out $(CI_REMOVE_OK_LOGS); \
$(JLOG) "Tests compilation status - $$type" test/$(BIN) $$type $(CI_REMOVE_OK_LOGS) $(CI_GITHUB); \
$(JLOG) "Tests execution status - $$type" test/$(BIN) $$type.out $(CI_REMOVE_OK_LOGS) $(CI_GITHUB); \
done
$(JCHK)
$(JLOG) "Checksums status" test/$(BIN) checksum*.ok $(CI_REMOVE_OK_LOGS);
$(JLOG) "Checksums status" test/$(BIN) checksum*.ok $(CI_REMOVE_OK_LOGS) $(CI_GITHUB);

logs: $(LOGS)

Expand Down