Phase 3: reference programs and schedule stress mode
- program_parallel_map: four exclusive loans of disjoint quarters - program_channel_transfer: heap-owned messages moved through a bounded channel; the 64-byte budget fits exactly the bounded worst case - program_tcp_echo_tasks: server task, one echo task per connection, two client tasks sharing address and message by shared loans - runner --stress N: seeds 0..N-1 under quanta 1, 2, 7 and the test's own; failures print the replay command; CI runs --stress 200 - plan: P3-12, P3-13 done
This commit is contained in:
1 parent
929132c81d
commit
9f322cfe31
7 files changed
+453
-7
No files matched your search
+36
-4
@@ -1,6 +1,10 @@
|
||||
//! Conformance suite runner. Format: tests/conformance/README.md.
|
||||
//!
|
||||
//! usage: aji-conformance <dir> [--json] [--filter <substring>]
|
||||
//! usage: aji-conformance <dir> [--json] [--filter <substring>] [--stress <seeds>]
|
||||
//!
|
||||
//! `--stress N` (P3-12): every test with a `schedules:` header runs schedule
|
||||
//! seeds 0 … N-1 under each quantum of `stress_quanta` and its own quantum,
|
||||
//! instead of its `schedules:` count. A failure prints the replay command.
|
||||
//!
|
||||
//! Exit status is 1 if any test FAILs or has a malformed header. PENDING
|
||||
//! (pipeline stage not implemented yet) does not fail the run.
|
||||
@@ -58,7 +62,7 @@ pub fn main(init: std.process.Init) !void {
|
||||
const args = try init.minimal.args.toSlice(arena);
|
||||
|
||||
if (args.len < 2) {
|
||||
std.debug.print("usage: aji-conformance <dir> [--json] [--filter <substring>]\n", .{});
|
||||
std.debug.print("usage: aji-conformance <dir> [--json] [--filter <substring>] [--stress <seeds>]\n", .{});
|
||||
std.process.exit(2);
|
||||
}
|
||||
const root = args[1];
|
||||
@@ -71,6 +75,12 @@ pub fn main(init: std.process.Init) !void {
|
||||
} else if (std.mem.eql(u8, args[i], "--filter") and i + 1 < args.len) {
|
||||
i += 1;
|
||||
filter = args[i];
|
||||
} else if (std.mem.eql(u8, args[i], "--stress") and i + 1 < args.len) {
|
||||
i += 1;
|
||||
stress_seeds = std.fmt.parseInt(u64, args[i], 10) catch {
|
||||
std.debug.print("aji-conformance: --stress needs a seed count\n", .{});
|
||||
std.process.exit(2);
|
||||
};
|
||||
} else {
|
||||
std.debug.print("aji-conformance: unknown argument {s}\n", .{args[i]});
|
||||
std.process.exit(2);
|
||||
@@ -119,6 +129,13 @@ pub fn main(init: std.process.Init) !void {
|
||||
if (counts.get(.fail) != 0) std.process.exit(1);
|
||||
}
|
||||
|
||||
/// Seeds per quantum under `--stress`; null runs each test's `schedules:`.
|
||||
var stress_seeds: ?u64 = null;
|
||||
|
||||
/// Quanta of the stress mode: forced yield after every instruction, short
|
||||
/// and odd slices (spec 04 §36.3); the test's own quantum is added.
|
||||
const stress_quanta = [_]u64{ 1, 2, 7 };
|
||||
|
||||
fn lessThan(_: void, a: []const u8, b: []const u8) bool {
|
||||
return std.mem.lessThan(u8, a, b);
|
||||
}
|
||||
@@ -165,7 +182,7 @@ fn runOne(arena: std.mem.Allocator, path: []const u8, source: []const u8) !Resul
|
||||
switch (header.expect) {
|
||||
.accept => if (report.status == .accepted) return .{ .outcome = .pass },
|
||||
.reject => |want| if (report.status == .rejected and eqlCodes(want, got.items)) return .{ .outcome = .pass },
|
||||
.run => |want| if (report.status == .accepted) return runModule(arena, report.module.?, want, header),
|
||||
.run => |want| if (report.status == .accepted) return runModule(arena, path, report.module.?, want, header),
|
||||
}
|
||||
return .{ .outcome = .fail, .detail = try std.fmt.allocPrint(arena, "expected {f}, got {t} {s}", .{
|
||||
fmtExpect(header.expect), report.status, try std.mem.join(arena, " ", got.items),
|
||||
@@ -176,7 +193,22 @@ fn runOne(arena: std.mem.Allocator, path: []const u8, source: []const u8) !Resul
|
||||
/// before comparing against the expectation.
|
||||
/// Runs the module once per schedule seed; every seed must satisfy the
|
||||
/// expectation (spec 04 §36.5). The program seed stays unchanged.
|
||||
fn runModule(arena: std.mem.Allocator, module: aji.air.Module, want: Expect.Run, header: Header) !Result {
|
||||
fn runModule(arena: std.mem.Allocator, path: []const u8, module: aji.air.Module, want: Expect.Run, header: Header) !Result {
|
||||
if (stress_seeds) |n| if (header.schedules > 1) {
|
||||
for (stress_quanta ++ [_]u64{header.quantum}) |q| {
|
||||
var h = header;
|
||||
h.quantum = q;
|
||||
var seed: u64 = 0;
|
||||
while (seed < n) : (seed += 1) {
|
||||
const r = try runSeed(arena, module, want, h, seed);
|
||||
if (r.outcome == .pass) continue;
|
||||
var grants: std.Io.Writer.Allocating = .init(arena);
|
||||
for (header.grants) |g| try grants.writer.print(" --grant {s}={s}{s}{s}", .{ g.parameter, g.kind, if (g.scope != null) ":" else "", g.scope orelse "" });
|
||||
return .{ .outcome = r.outcome, .detail = try std.fmt.allocPrint(arena, "quantum {d}, schedule seed {d}: {s}; replay: aji run --quantum {d} --schedule-seed {d}{s} {s}", .{ q, seed, r.detail, q, seed, grants.written(), path }) };
|
||||
}
|
||||
}
|
||||
return .{ .outcome = .pass };
|
||||
};
|
||||
var seed: u64 = 0;
|
||||
while (seed < header.schedules) : (seed += 1) {
|
||||
const r = try runSeed(arena, module, want, header, if (header.schedules > 1) seed else null);
|
||||
|
||||
Reference in new issue
Block a user