Skip to content

Commit 3a4e67b

Browse files
committed
feat: Add vendor test infrastructure framework
- Add vendor test numbering scheme in acs_common.h (10000+ range) - Add vendor test template and documentation in test_pool/vendor/ - Add verify_vendor_inf.sh script to check vendor INFs are in sync - Update acsbuild.sh to support vendor builds with two-argument syntax - Vendor builds auto-verify upstream sync before building Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
1 parent 3ca6861 commit 3a4e67b

File tree

6 files changed

+674
-24
lines changed

6 files changed

+674
-24
lines changed

apps/uefi/vendor/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Vendor INF Files
2+
3+
Vendor-specific INF files that extend public sysarch-acs with vendor tests.
4+
5+
## Architecture
6+
7+
```
8+
apps/uefi/
9+
├── Bsa.inf # Public BSA
10+
├── Sbsa.inf # Public SBSA
11+
├── xbsa_acpi.inf # Public xBSA ACPI
12+
└── vendor/
13+
├── verify_vendor_inf.sh # Sync verification script
14+
└── nvidia/
15+
├── BsaNvidia.inf # BSA + NVIDIA tests
16+
├── SbsaNvidia.inf # SBSA + NVIDIA tests
17+
└── XbsaAcpiNvidia.inf # xBSA ACPI + NVIDIA tests
18+
```
19+
20+
## Build Commands
21+
22+
```bash
23+
# Public builds (no vendor argument)
24+
source acsbuild.sh bsa
25+
source acsbuild.sh sbsa
26+
source acsbuild.sh xbsa_acpi
27+
28+
# Vendor builds (add vendor name as second argument)
29+
source acsbuild.sh bsa nvidia
30+
source acsbuild.sh sbsa nvidia
31+
source acsbuild.sh xbsa_acpi nvidia
32+
```
33+
34+
## Build-Time Sync Check
35+
36+
Vendor builds automatically verify that vendor INFs include all upstream tests.
37+
If sync is broken, the build fails and shows missing tests.
38+
39+
Manual verification:
40+
```bash
41+
./apps/uefi/vendor/verify_vendor_inf.sh nvidia
42+
```
43+
44+
## Adding a New Vendor
45+
46+
1. Create directory: `apps/uefi/vendor/<vendor>/`
47+
48+
2. Create vendor INFs (copy from nvidia/ and modify):
49+
- Change `BASE_NAME` and `FILE_GUID`
50+
- Capitalize vendor name in INF filename (e.g., `BsaQualcomm.inf`)
51+
- Update paths and vendor test sources
52+
53+
3. The build script auto-detects vendor INFs by naming convention:
54+
- `<AcsType><Vendor>.inf` (e.g., `BsaNvidia.inf`, `XbsaAcpiQualcomm.inf`)
55+
56+
## Syncing with Upstream
57+
58+
When upstream adds/removes tests:
59+
1. Run `./verify_vendor_inf.sh <vendor>` to find missing tests
60+
2. Update vendor INFs accordingly
61+
3. Re-verify before building
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
#!/bin/bash
2+
## @file
3+
# Verify vendor INF files include all upstream tests
4+
#
5+
# Copyright (c) 2025, Arm Limited or its affiliates. All rights reserved.
6+
# SPDX-License-Identifier : Apache-2.0
7+
#
8+
# Usage: ./verify_vendor_inf.sh [vendor_name]
9+
# ./verify_vendor_inf.sh nvidia
10+
# ./verify_vendor_inf.sh # verifies all vendors
11+
##
12+
13+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14+
APPS_DIR="$(dirname "$SCRIPT_DIR")"
15+
16+
# Extract test sources from an INF file (excluding vendor tests and app sources)
17+
extract_test_sources() {
18+
local inf_file="$1"
19+
grep -E '^\s*(\.\./)*test_pool/' "$inf_file" | \
20+
grep -v 'vendor/' | \
21+
sed 's|.*test_pool/|test_pool/|' | \
22+
sed 's|\.c.*|.c|' | \
23+
sort -u
24+
}
25+
26+
# Compare upstream and vendor INF
27+
verify_inf_pair() {
28+
local upstream_inf="$1"
29+
local vendor_inf="$2"
30+
local upstream_name=$(basename "$upstream_inf" .inf)
31+
local vendor_name=$(basename "$vendor_inf" .inf)
32+
33+
if [ ! -f "$upstream_inf" ]; then
34+
echo "ERROR: Upstream INF not found: $upstream_inf"
35+
return 1
36+
fi
37+
38+
if [ ! -f "$vendor_inf" ]; then
39+
echo "ERROR: Vendor INF not found: $vendor_inf"
40+
return 1
41+
fi
42+
43+
echo "Checking: $upstream_name -> $vendor_name"
44+
45+
# Extract sources
46+
local upstream_sources=$(extract_test_sources "$upstream_inf")
47+
local vendor_sources=$(extract_test_sources "$vendor_inf")
48+
49+
# Find missing sources
50+
local missing=""
51+
for src in $upstream_sources; do
52+
if ! echo "$vendor_sources" | grep -q "^${src}$"; then
53+
missing="$missing - $src\n"
54+
fi
55+
done
56+
57+
if [ -n "$missing" ]; then
58+
echo " FAIL: Missing tests in $vendor_name:"
59+
echo -e "$missing"
60+
return 1
61+
else
62+
echo " PASS: All upstream tests present"
63+
return 0
64+
fi
65+
}
66+
67+
# Verify a vendor
68+
verify_vendor() {
69+
local vendor="$1"
70+
local vendor_dir="$SCRIPT_DIR/$vendor"
71+
local errors=0
72+
local found_infs=0
73+
74+
echo "========================================"
75+
echo "Verifying vendor: $vendor"
76+
echo "========================================"
77+
78+
# Check if vendor directory exists
79+
if [ ! -d "$vendor_dir" ]; then
80+
echo "WARNING: Vendor directory not found: $vendor_dir"
81+
echo " No vendor INFs to verify (this is OK if vendor tests not yet added)"
82+
return 0
83+
fi
84+
85+
# Check each INF file in vendor directory
86+
# Look for pattern: <AcsType><Vendor>.inf (e.g., BsaNvidia.inf, UnifiedNvidia.inf)
87+
for vendor_inf in "$vendor_dir"/*.inf; do
88+
[ -f "$vendor_inf" ] || continue
89+
90+
local inf_basename=$(basename "$vendor_inf" .inf)
91+
92+
# Skip if doesn't match vendor naming pattern
93+
# Extract the ACS type by removing vendor name suffix (case insensitive)
94+
local vendor_upper="${vendor^}" # Capitalize first letter
95+
local acs_type=$(echo "$inf_basename" | sed "s/${vendor_upper}$//i")
96+
97+
# Skip if no ACS type extracted (means it's not a vendor INF)
98+
[ -z "$acs_type" ] && continue
99+
[ "$acs_type" == "$inf_basename" ] && continue
100+
101+
((found_infs++))
102+
103+
# Determine upstream INF name
104+
local upstream_inf="$APPS_DIR/${acs_type}.inf"
105+
106+
if [ -f "$upstream_inf" ]; then
107+
verify_inf_pair "$upstream_inf" "$vendor_inf" || ((errors++))
108+
else
109+
echo "WARNING: No upstream INF found for $vendor_inf (expected: $upstream_inf)"
110+
fi
111+
done
112+
113+
if [ $found_infs -eq 0 ]; then
114+
echo " No vendor INF files found (this is OK if vendor tests not yet added)"
115+
return 0
116+
fi
117+
118+
return $errors
119+
}
120+
121+
# Main
122+
main() {
123+
local total_errors=0
124+
local vendors_checked=0
125+
126+
if [ -n "$1" ]; then
127+
# Verify specific vendor
128+
verify_vendor "$1"
129+
total_errors=$?
130+
vendors_checked=1
131+
else
132+
# Verify all vendors
133+
for vendor_dir in "$SCRIPT_DIR"/*/; do
134+
[ -d "$vendor_dir" ] || continue
135+
vendor=$(basename "$vendor_dir")
136+
[ "$vendor" = "." ] && continue
137+
[ "$vendor" = "template" ] && continue # Skip template directory
138+
verify_vendor "$vendor"
139+
[ $? -ne 0 ] && ((total_errors++))
140+
((vendors_checked++))
141+
done
142+
fi
143+
144+
echo ""
145+
if [ $vendors_checked -eq 0 ]; then
146+
echo "No vendor directories found. Vendor infrastructure ready for use."
147+
exit 0
148+
elif [ $total_errors -eq 0 ]; then
149+
echo "All vendor INF files are in sync with upstream."
150+
exit 0
151+
else
152+
echo "ERROR: $total_errors vendor(s) have sync issues."
153+
echo "Please update vendor INF files to match upstream."
154+
exit 1
155+
fi
156+
}
157+
158+
main "$@"

test_pool/vendor/README.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Vendor Test Pool
2+
3+
This directory contains vendor-specific tests that extend the standard BSA/SBSA test suites.
4+
5+
## Directory Structure
6+
7+
```
8+
vendor/
9+
├── README.md # This file
10+
├── nvidia/ # NVIDIA-specific tests
11+
│ ├── README.md # NVIDIA vendor test documentation
12+
│ └── timer/ # Timer-related vendor tests
13+
│ ├── vt001.c # Vendor timer test 001
14+
│ └── ...
15+
├── <vendor>/ # Other vendor directories
16+
│ └── ...
17+
└── template/ # Template for new vendor tests
18+
└── vtest_template.c
19+
```
20+
21+
## Adding Vendor Tests
22+
23+
### 1. Create Vendor Directory
24+
25+
Create a new directory under `vendor/` with your vendor name (lowercase):
26+
27+
```bash
28+
mkdir -p test_pool/vendor/<vendor_name>/timer
29+
```
30+
31+
### 2. Test Numbering Convention
32+
33+
Vendor tests use a separate numbering space to avoid conflicts with standard tests:
34+
35+
```c
36+
/* Standard test numbering (reserved 0-9999) */
37+
#define ACS_TIMER_TEST_NUM_BASE 400
38+
39+
/* Vendor test numbering (10000+) */
40+
#define ACS_VENDOR_TEST_NUM_BASE 10000
41+
42+
/* Per-vendor offsets (1000 tests per vendor) */
43+
#define ACS_VENDOR_NVIDIA_BASE (ACS_VENDOR_TEST_NUM_BASE + 0)
44+
#define ACS_VENDOR_QUALCOMM_BASE (ACS_VENDOR_TEST_NUM_BASE + 1000)
45+
#define ACS_VENDOR_MEDIATEK_BASE (ACS_VENDOR_TEST_NUM_BASE + 2000)
46+
/* Add more vendors as needed */
47+
48+
/* Module offsets within vendor space (100 tests per module) */
49+
#define VENDOR_TIMER_OFFSET 0
50+
#define VENDOR_PCIE_OFFSET 100
51+
#define VENDOR_PE_OFFSET 200
52+
/* ... */
53+
```
54+
55+
### 3. Test File Naming
56+
57+
Vendor tests should be named with a `v` prefix:
58+
- `vt001.c` - Vendor timer test 001
59+
- `vp001.c` - Vendor PCIe test 001
60+
- `vpe001.c` - Vendor PE test 001
61+
62+
### 4. Test Rule ID Convention
63+
64+
Use vendor-prefixed rule IDs:
65+
```c
66+
#define TEST_RULE "NVIDIA_TIME_01" /* Vendor-specific rule */
67+
```
68+
69+
### 5. Creating a Test
70+
71+
Copy the template and modify:
72+
73+
```c
74+
#include "val/include/acs_val.h"
75+
#include "val/include/acs_timer.h"
76+
#include "val/include/acs_pe.h"
77+
78+
/* Test identification */
79+
#define TEST_NUM (ACS_VENDOR_NVIDIA_BASE + VENDOR_TIMER_OFFSET + 1)
80+
#define TEST_DESC "NVIDIA: Custom timer validation"
81+
#define TEST_RULE "NVIDIA_TIME_01"
82+
83+
static void payload(uint32_t num_pe)
84+
{
85+
uint32_t index = val_pe_get_index_mpid(val_pe_get_mpid());
86+
87+
/* Your test logic here */
88+
89+
val_set_status(index, RESULT_PASS(TEST_NUM, 1));
90+
}
91+
92+
uint32_t
93+
vt001_entry(uint32_t num_pe)
94+
{
95+
uint32_t status = ACS_STATUS_FAIL;
96+
97+
status = val_initialize_test(TEST_NUM, TEST_DESC, val_pe_get_num());
98+
if (status != ACS_STATUS_SKIP)
99+
payload(num_pe);
100+
101+
status = val_check_for_error(TEST_NUM, 1, TEST_RULE);
102+
val_report_status(0, ACS_END(TEST_NUM), TEST_RULE);
103+
104+
return status;
105+
}
106+
```
107+
108+
### 6. Registering Vendor Tests
109+
110+
Add your test entry point to the appropriate execute file or create a vendor-specific executor.
111+
112+
## Running Vendor Tests
113+
114+
### Run All Vendor Tests
115+
```bash
116+
xbsa_acpi.efi -m VENDOR -v 1
117+
```
118+
119+
### Run Specific Vendor Tests
120+
```bash
121+
xbsa_acpi.efi -r NVIDIA_TIME_01 -v 1
122+
```
123+
124+
### Run Standard + Vendor Tests
125+
```bash
126+
xbsa_acpi.efi -m BSA,VENDOR -v 1
127+
```
128+
129+
## Build Architecture
130+
131+
```
132+
apps/uefi/
133+
├── xbsa_acpi.inf # Public INF (unchanged from upstream)
134+
└── vendor/nvidia/
135+
└── XbsaAcpiNvidia.inf # Public tests + NVIDIA vendor tests
136+
```
137+
138+
Vendor INF files copy the public test list and add vendor tests at the end.
139+
When upstream is updated, sync the test list in vendor INF files.
140+
141+
### DSC Integration
142+
143+
```ini
144+
[Components]
145+
# Public build
146+
ShellPkg/Application/sysarch-acs/apps/uefi/xbsa_acpi.inf
147+
148+
# OR NVIDIA internal build
149+
ShellPkg/Application/sysarch-acs/apps/uefi/vendor/nvidia/XbsaAcpiNvidia.inf
150+
```
151+
152+
## Guidelines
153+
154+
1. **Isolation**: Vendor tests should not modify or depend on standard test behavior
155+
2. **Documentation**: Each vendor directory must have a README.md
156+
3. **Compatibility**: Use only public VAL/PAL APIs
157+
4. **Naming**: Follow the naming conventions strictly
158+
5. **Testing**: Ensure vendor tests pass on the target platform before submission
159+
160+
## Contact
161+
162+
For questions about adding vendor tests, contact the sysarch-acs maintainers.
163+

0 commit comments

Comments
 (0)