Skip to content

Commit

Permalink
Tweak optional CI run execution. (#4380)
Browse files Browse the repository at this point in the history
* Tweak optional CI run execution.

* Fix incorrect TC code.

* Add a sleep for the BMv2 PTF test.
  • Loading branch information
fruffy authored Jan 31, 2024
1 parent 99ac793 commit 1e7c32a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci-ubuntu-18-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ on:
- cron: "0 0 * * *"
pull_request:
branches: [main]
push:
branches: [main]

jobs:
# Build with gcc and test p4c on Ubuntu 18.04.
test-ubuntu18:
# Only run on pull requests with the "run-ubuntu18" label.
if: contains(github.event.pull_request.labels.*.name, 'run-ubuntu18')
if: ${{ github.event_name == 'schedule' }} or contains(github.event.pull_request.labels.*.name, 'run-ubuntu18')
strategy:
fail-fast: false
runs-on: ubuntu-latest
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ci-ubuntu-20-sanitizer-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ on:
# Every day on midnight UTC
- cron: "0 0 * * *"
pull_request:
branches:
- main
branches: [main]
push:
branches: [main]

jobs:
# Build with clang and test p4c on Ubuntu 20.04.
test-ubuntu20-clang-sanitizers:
# Only run on pull requests with the "run-sanitizer" label.
if: contains(github.event.pull_request.labels.*.name, 'run-sanitizer')
if: ${{ github.event_name == 'schedule' }} or contains(github.event.pull_request.labels.*.name, 'run-sanitizer')
strategy:
fail-fast: false
runs-on: ubuntu-20.04
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ci-validation-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ on:
# Every day on midnight UTC
- cron: "0 0 * * *"
pull_request:
branches:
- main
branches: [main]
push:
branches: [main]

jobs:
# We run validation in parallel with the normal tests.
# Validation ensures that P4C compiles P4-16 programs correctly.
# We only test the front end and some mid end passes for now.
validate:
# Only run on pull requests with the "run-validation" label.
if: contains(github.event.pull_request.labels.*.name, 'run-validation')
if: ${{ github.event_name == 'schedule' }} or contains(github.event.pull_request.labels.*.name, 'run-validation')
env:
CTEST_PARALLEL_LEVEL: 4
IMAGE_TYPE: test
Expand Down
1 change: 0 additions & 1 deletion backends/bmv2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ add_dependencies(p4c_driver linkbmv2)


# Tests

set(BMV2_DRIVER ${CMAKE_CURRENT_SOURCE_DIR}/run-bmv2-test.py)
set(BMV2_PTF_DRIVER "$([[ $EUID = 0 ]] || echo 'sudo -E') ${CMAKE_CURRENT_SOURCE_DIR}/run-bmv2-ptf-test.py")

Expand Down
5 changes: 4 additions & 1 deletion backends/bmv2/run-bmv2-ptf-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import random
import sys
import tempfile
import time
import uuid
from datetime import datetime
from pathlib import Path
Expand Down Expand Up @@ -257,7 +258,7 @@ def run_test(options: Options) -> int:
Optional: Run the generated model"""
test_name = Path(options.p4_file.name)
json_name = options.testdir.joinpath(test_name.with_suffix(".json"))
info_name = options.testdir.joinpath(test_name.with_suffix(".p4info.txt"))
info_name = options.testdir.joinpath(test_name.with_suffix(".p4info.txtpb"))
# Copy the test file into the test folder so that it can be picked up by PTF.
testutils.copy_file(options.testfile, options.testdir)

Expand All @@ -277,6 +278,8 @@ def run_test(options: Options) -> int:
switch_proc = testenv.run_simple_switch_grpc(switchlog, grpc_port)
if switch_proc is None:
return testutils.FAILURE
# Breath a little.
time.sleep(1)
# Run the PTF test and retrieve the result.
result = testenv.run_ptf(grpc_port, json_name, info_name)
# Delete the test environment and trigger a clean up.
Expand Down
6 changes: 3 additions & 3 deletions backends/tc/ebpfCodeGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class ConvertToEBPFControlPNA : public Inspector {
bool preorder(const IR::Declaration_Variable *) override;
bool preorder(const IR::Member *m) override;
bool preorder(const IR::IfStatement *a) override;
bool preorder(const IR::ExternBlock *instance);
bool preorder(const IR::ExternBlock *instance) override;
bool checkPnaTimestampMem(const IR::Member *m);
EBPF::EBPFControlPSA *getEBPFControl() { return control; }
};
Expand Down Expand Up @@ -305,8 +305,8 @@ class ControlBodyTranslatorPNA : public EBPF::ControlBodyTranslator {
explicit ControlBodyTranslatorPNA(const EBPF::EBPFControlPSA *control,
const ConvertToBackendIR *tcIR,
const EBPF::EBPFTablePSA *table);
void processFunction(const P4::ExternFunction *function);
void processApply(const P4::ApplyMethod *method);
void processFunction(const P4::ExternFunction *function) override;
void processApply(const P4::ApplyMethod *method) override;
bool checkPnaPortMem(const IR::Member *m);
virtual cstring getParamName(const IR::PathExpression *);
bool preorder(const IR::AssignmentStatement *a) override;
Expand Down

0 comments on commit 1e7c32a

Please sign in to comment.