ktstr 0.10.0

Test harness for Linux process schedulers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
//! Unit tests for `MonitorThresholds::evaluate`: default values,
//! balanced/imbalanced load, DSQ depth, stuck rq_clock, validity
//! guards, and the `enforce` flag default.
//! Co-located via the sibling `*_tests.rs` pattern.

#![cfg(test)]

use super::test_util::balanced_sample;
use super::*;

/// Wire-format pin: `enforce` defaults to `false` (report-only
/// mode). Tests that want hard pass/fail must explicitly set
/// `enforce: true` in their `MonitorThresholds` literal OR use the
/// `Assert` builder's `.with_monitor_defaults()` helper (which sets
/// `enforce_monitor_thresholds = true`).
///
/// Without this canary, a future commit that flips the default back
/// to `enforce: true` (or any other value) would silently re-enable
/// enforcement for all tests using `..Default::default()` or
/// `MonitorThresholds::new()` — masking real bugs that the
/// report-only mode is designed to surface as warnings instead of
/// failures.
#[test]
fn enforce_defaults_to_false() {
    let t = MonitorThresholds::default();
    assert!(
        !t.enforce,
        "enforce must default to false (report-only mode)"
    );
    let d = MonitorThresholds::new();
    assert!(!d.enforce, "DEFAULT.enforce must match default()");
}

#[test]
fn thresholds_default_values() {
    // Regression guard for `MonitorThresholds::new()`. Every
    // field is asserted: changing a default silently shifts what
    // "passes by default" across every test that inherits
    // defaults via `Assert::default_checks()` + per-scheduler
    // merge. If a default moves, the rationale belongs in the
    // doc comment on `DEFAULT` first; the test failure then
    // prompts the rationale update.
    let t = MonitorThresholds::default();
    assert!(
        (t.max_imbalance_ratio - 4.0).abs() < f64::EPSILON,
        "default max_imbalance_ratio drifted: {}",
        t.max_imbalance_ratio,
    );
    assert_eq!(
        t.max_local_dsq_depth, 50,
        "default max_local_dsq_depth drifted",
    );
    assert!(t.fail_on_stall, "default fail_on_stall drifted");
    assert_eq!(t.sustained_samples, 5, "default sustained_samples drifted");
    assert!(
        (t.max_fallback_rate - 200.0).abs() < f64::EPSILON,
        "default max_fallback_rate drifted: {}",
        t.max_fallback_rate,
    );
    assert!(
        (t.max_keep_last_rate - 100.0).abs() < f64::EPSILON,
        "default max_keep_last_rate drifted: {}",
        t.max_keep_last_rate,
    );
}

#[test]
fn thresholds_default_matches_const() {
    // `Default::default()` and `DEFAULT` must agree — the impl
    // forwards, but the forward is a single expression that a
    // drive-by refactor could break.
    let a = MonitorThresholds::default();
    let b = MonitorThresholds::new();
    assert!((a.max_imbalance_ratio - b.max_imbalance_ratio).abs() < f64::EPSILON);
    assert_eq!(a.max_local_dsq_depth, b.max_local_dsq_depth);
    assert_eq!(a.fail_on_stall, b.fail_on_stall);
    assert_eq!(a.sustained_samples, b.sustained_samples);
    assert!((a.max_fallback_rate - b.max_fallback_rate).abs() < f64::EPSILON);
    assert!((a.max_keep_last_rate - b.max_keep_last_rate).abs() < f64::EPSILON);
}

#[test]
fn thresholds_balanced_samples_pass() {
    let t = MonitorThresholds::default();
    let samples: Vec<_> = (0..10)
        .map(|i| balanced_sample(i * 100, 1000 + i * 500))
        .collect();
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(v.passed, "balanced samples should pass: {:?}", v.details);
}

#[test]
fn thresholds_imbalance_below_sustained_passes() {
    let t = MonitorThresholds {
        sustained_samples: 5,
        max_imbalance_ratio: 4.0,
        ..Default::default()
    };
    // 4 consecutive imbalanced samples (below sustained_samples=5).
    let mut samples = Vec::new();
    for i in 0..4 {
        samples.push(MonitorSample {
            prog_stats: None,
            elapsed_ms: i * 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 1000 + i * 500,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 10,
                    rq_clock: 1100 + i * 500,
                    ..Default::default()
                },
            ],
        });
    }
    // Then a balanced one to break the streak.
    samples.push(balanced_sample(400, 3000));
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(
        v.is_pass(),
        "4 imbalanced < sustained_samples=5: {:?}",
        v.details
    );
}

#[test]
fn thresholds_imbalance_at_sustained_fails() {
    let t = MonitorThresholds {
        sustained_samples: 5,
        max_imbalance_ratio: 4.0,
        enforce: true,
        ..Default::default()
    };
    // 5 consecutive imbalanced samples (ratio=10, threshold=4).
    let mut samples = Vec::new();
    for i in 0..5u64 {
        samples.push(MonitorSample {
            prog_stats: None,
            elapsed_ms: i * 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 1000 + i * 500,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 10,
                    rq_clock: 1100 + i * 500,
                    ..Default::default()
                },
            ],
        });
    }
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(v.is_fail());
    assert!(v.details.iter().any(|d| d.contains("imbalance")));
}

#[test]
fn thresholds_dsq_depth_sustained_fails() {
    let t = MonitorThresholds {
        sustained_samples: 3,
        max_local_dsq_depth: 10,
        fail_on_stall: false,
        enforce: true,
        ..Default::default()
    };
    let mut samples = Vec::new();
    for i in 0..3u64 {
        samples.push(MonitorSample {
            prog_stats: None,
            elapsed_ms: i * 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 2,
                    local_dsq_depth: 20,
                    rq_clock: 1000 + i * 500,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 2,
                    local_dsq_depth: 5,
                    rq_clock: 1100 + i * 500,
                    ..Default::default()
                },
            ],
        });
    }
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(v.is_fail());
    assert!(v.details.iter().any(|d| d.contains("DSQ depth")));
}

#[test]
fn thresholds_dsq_depth_below_sustained_passes() {
    let t = MonitorThresholds {
        sustained_samples: 3,
        max_local_dsq_depth: 10,
        fail_on_stall: false,
        ..Default::default()
    };
    // Only 2 consecutive DSQ violations, then a clean sample.
    let mut samples = Vec::new();
    for i in 0..2u64 {
        samples.push(MonitorSample {
            prog_stats: None,
            elapsed_ms: i * 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 2,
                    local_dsq_depth: 20,
                    rq_clock: 1000 + i * 500,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 2,
                    local_dsq_depth: 5,
                    rq_clock: 1100 + i * 500,
                    ..Default::default()
                },
            ],
        });
    }
    samples.push(balanced_sample(200, 2000));
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(v.passed, "2 DSQ violations < sustained=3: {:?}", v.details);
}

#[test]
fn thresholds_stuck_detected_fails() {
    // Stuck checks use the sustained_samples window. With sustained_samples=1,
    // a single stuck pair triggers failure. `enforce: true` opts out of
    // the report-only default so the violation flips `passed` to false.
    let t = MonitorThresholds {
        fail_on_stall: true,
        sustained_samples: 1,
        enforce: true,
        ..Default::default()
    };
    let samples = vec![
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 5000,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 6000,
                    ..Default::default()
                },
            ],
        },
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 200,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 5000,
                    ..Default::default()
                }, // stuck
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 7000,
                    ..Default::default()
                },
            ],
        },
    ];
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(v.is_fail());
    assert!(v.details.iter().any(|d| d.contains("rq_clock stall")));
}

#[test]
fn thresholds_stuck_disabled_passes() {
    // Test the `fail_on_stall: false` toggle: a CPU with a
    // stuck `rq_clock` must NOT fail the verdict when stall
    // detection is disabled. The setup uses 2 CPUs with mixed
    // rq_clock (cpu0 stuck at 5000/5000, cpu1 advancing
    // 6000/7500) so `data_looks_valid` returns true (rq_clocks
    // are not all identical) and the no-signal Inconclusive
    // arm doesn't fire — the test isolates the
    // `fail_on_stall=false` toggle from the data-validity
    // path.
    let t = MonitorThresholds {
        fail_on_stall: false,
        sustained_samples: 100,
        ..Default::default()
    };
    let samples = vec![
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 5000,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 6000,
                    ..Default::default()
                },
            ],
        },
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 200,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 5000,
                    ..Default::default()
                }, // cpu0 stuck but stall check disabled
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 7500,
                    ..Default::default()
                }, // cpu1 advancing so data_looks_valid passes
            ],
        },
    ];
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(
        v.is_pass(),
        "fail_on_stall=false must pass even with stuck cpu0: {:?}",
        v.details
    );
}

#[test]
fn thresholds_imbalance_interrupted_by_balanced_resets() {
    // 3 imbalanced, 1 balanced, 3 imbalanced — never reaches sustained=5.
    let t = MonitorThresholds {
        sustained_samples: 5,
        max_imbalance_ratio: 4.0,
        fail_on_stall: false,
        ..Default::default()
    };
    let mut samples = Vec::new();
    for i in 0..3u64 {
        samples.push(MonitorSample {
            prog_stats: None,
            elapsed_ms: i * 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 1000 + i * 500,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 10,
                    rq_clock: 1100 + i * 500,
                    ..Default::default()
                },
            ],
        });
    }
    samples.push(balanced_sample(300, 2500));
    for i in 4..7u64 {
        samples.push(MonitorSample {
            prog_stats: None,
            elapsed_ms: i * 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 3000 + i * 500,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 10,
                    rq_clock: 3100 + i * 500,
                    ..Default::default()
                },
            ],
        });
    }
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(
        v.is_pass(),
        "interrupted imbalance should pass: {:?}",
        v.details
    );
}

#[test]
fn thresholds_multiple_violations() {
    // Both imbalance and stall in the same report. Both need to
    // reach sustained_samples to trigger. 3 samples = 2 consecutive
    // stall pairs for cpu0 (clock stuck at 1000), 2 consecutive
    // imbalance violations (ratio=5.0 > 2.0).
    let t = MonitorThresholds {
        sustained_samples: 2,
        max_imbalance_ratio: 2.0,
        fail_on_stall: true,
        enforce: true,
        ..Default::default()
    };
    let samples = vec![
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 1000,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 5,
                    rq_clock: 2000,
                    ..Default::default()
                },
            ],
        },
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 200,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 1000,
                    ..Default::default()
                }, // stall + imbalance
                CpuSnapshot {
                    nr_running: 5,
                    rq_clock: 3000,
                    ..Default::default()
                },
            ],
        },
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 300,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 1000,
                    ..Default::default()
                }, // stall continues
                CpuSnapshot {
                    nr_running: 5,
                    rq_clock: 4000,
                    ..Default::default()
                },
            ],
        },
    ];
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(v.is_fail());
    assert!(v.details.iter().any(|d| d.contains("imbalance")));
    assert!(v.details.iter().any(|d| d.contains("rq_clock stall")));
}

#[test]
fn thresholds_empty_samples_vec_yields_inconclusive() {
    // Empty samples vec — monitor produced no data at all (the
    // earliest Inconclusive arm in evaluate). Pin that this surfaces
    // as Inconclusive (not Pass), distinct from the populated-but-
    // empty-cpus case which legitimately passes.
    let t = MonitorThresholds::default();
    let report = MonitorReport {
        samples: vec![],
        summary: MonitorSummary::from_samples(&[]),
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(
        v.is_inconclusive(),
        "no samples must surface as Inconclusive (not Pass) — silent-pass guard. \
         Got is_pass={}, is_fail={}, summary={}",
        v.is_pass(),
        v.is_fail(),
        v.summary,
    );
    assert_eq!(
        v.summary, "no monitor samples",
        "summary text must match the dedicated no-samples narrative",
    );
}

#[test]
fn thresholds_empty_cpus_samples_pass() {
    let t = MonitorThresholds::default();
    let samples = vec![
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 100,
            cpus: vec![],
        },
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 200,
            cpus: vec![],
        },
    ];
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(v.is_pass());
}

#[test]
fn thresholds_uninitialized_memory_yields_inconclusive() {
    // Simulates what happens when monitor reads guest memory before
    // kernel initialization: all rq_clocks identical, DSQ depths
    // garbage. data_looks_valid rejects the sample, so the verdict
    // must be Inconclusive (not Pass) — passing on no-signal would
    // let a CI gate keying off is_pass treat "couldn't measure"
    // identically to "measured and OK", the silent-pass class the
    // Inconclusive arm exists to prevent.
    let t = MonitorThresholds::default();
    let garbage_clock = 10314579376562252011u64;
    let samples: Vec<_> = (0..10)
        .map(|i| MonitorSample {
            prog_stats: None,
            elapsed_ms: i * 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 0,
                    rq_clock: garbage_clock,
                    local_dsq_depth: 1550435906,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 0,
                    rq_clock: garbage_clock,
                    local_dsq_depth: 1550435906,
                    ..Default::default()
                },
            ],
        })
        .collect();
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(
        v.is_inconclusive(),
        "uninitialized guest memory must surface as Inconclusive (not Pass) — \
         silent-pass guard at the MonitorVerdict surface. Got is_pass={}, is_fail={}, summary={}",
        v.is_pass(),
        v.is_fail(),
        v.summary,
    );
    assert!(
        !v.is_pass(),
        "is_pass must be false on the Inconclusive arm (strict mutex)",
    );
}

#[test]
fn thresholds_all_same_clocks_yields_inconclusive() {
    // All clocks identical across all CPUs and samples = uninitialized.
    // data_looks_valid rejects, so the verdict is Inconclusive (not
    // Pass) — same silent-pass guard as
    // [`thresholds_uninitialized_memory_yields_inconclusive`].
    let t = MonitorThresholds {
        fail_on_stall: true,
        ..Default::default()
    };
    let samples = vec![
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 100,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 5000,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 5000,
                    ..Default::default()
                },
            ],
        },
        MonitorSample {
            prog_stats: None,
            elapsed_ms: 200,
            cpus: vec![
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 5000,
                    ..Default::default()
                },
                CpuSnapshot {
                    nr_running: 1,
                    rq_clock: 5000,
                    ..Default::default()
                },
            ],
        },
    ];
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(
        v.is_inconclusive(),
        "all-same clocks must surface as Inconclusive (not Pass) — \
         the no-signal arm cannot masquerade as a measured pass. Got is_pass={}, summary={}",
        v.is_pass(),
        v.summary,
    );
}

#[test]
fn thresholds_dsq_over_plausibility_ceiling_yields_inconclusive() {
    // sample_looks_valid rejects when any DSQ depth exceeds the
    // plausibility ceiling — the verdict is Inconclusive (not
    // Pass) so the operator sees "couldn't measure" rather than
    // a silent green light on garbage data.
    let t = MonitorThresholds::default();
    let samples = vec![MonitorSample {
        prog_stats: None,
        elapsed_ms: 100,
        cpus: vec![
            CpuSnapshot {
                nr_running: 1,
                rq_clock: 1000,
                local_dsq_depth: 50000,
                ..Default::default()
            },
            CpuSnapshot {
                nr_running: 1,
                rq_clock: 2000,
                local_dsq_depth: 5,
                ..Default::default()
            },
        ],
    }];
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(
        v.is_inconclusive(),
        "implausible DSQ depth must surface as Inconclusive (not Pass) — \
         silent-pass guard. Got is_pass={}, summary={}",
        v.is_pass(),
        v.summary,
    );
}

#[test]
fn thresholds_single_cpu_single_sample_valid() {
    // A single reading cannot be compared, so all_clocks_same with
    // total_readings=1 should still be treated as valid.
    let t = MonitorThresholds {
        fail_on_stall: true,
        sustained_samples: 1,
        enforce: true,
        ..Default::default()
    };
    let samples = vec![MonitorSample {
        prog_stats: None,
        elapsed_ms: 100,
        cpus: vec![CpuSnapshot {
            nr_running: 1,
            rq_clock: 5000,
            ..Default::default()
        }],
    }];
    let summary = MonitorSummary::from_samples(&samples);
    let report = MonitorReport {
        samples,
        summary,
        ..Default::default()
    };
    let v = t.evaluate(&report);
    assert!(v.passed, "single reading should be valid: {:?}", v.details);
}