MCPcopy Create free account
hub / github.com/aws/clock-bound / test_reader_version_not_supported

Function test_reader_version_not_supported

clock-bound/src/vmclock/shm_reader.rs:477–512  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

475 let vmclock_shm_tempfile = NamedTempFile::new().expect("create vmclock file failed");
476 let vmclock_shm_temppath = vmclock_shm_tempfile.into_temp_path();
477 let vmclock_shm_path = vmclock_shm_temppath.to_str().unwrap();
478 let mut vmclock_shm_file = OpenOptions::new()
479 .write(true)
480 .open(vmclock_shm_path)
481 .expect("open vmclock file failed");
482 let vmclock_content = VMClockContent {
483 magic: 0x4B4C4356,
484 size: 104_u32,
485 version: 999_u16,
486 counter_id: 1_u8,
487 time_type: 0_u8,
488 seq_count: 10_u32,
489 disruption_marker: 888888_u64,
490 flags: 0_u64,
491 _padding: [0x00, 0x00],
492 clock_status: VMClockClockStatus::Synchronized,
493 leap_second_smearing_hint: 0_u8,
494 tai_offset_sec: 0_i16,
495 leap_indicator: 0_u8,
496 counter_period_shift: 0_u8,
497 counter_value: 123456_u64,
498 counter_period_frac_sec: 0_u64,
499 counter_period_esterror_rate_frac_sec: 0_u64,
500 counter_period_maxerror_rate_frac_sec: 0_u64,
501 time_sec: 0_u64,
502 time_frac_sec: 0_u64,
503 time_esterror_nanosec: 0_u64,
504 time_maxerror_nanosec: 0_u64,
505 };
506 write_vmclock_content(&mut vmclock_shm_file, &vmclock_content);
507
508 assert!(VMClockShmReader::new(&vmclock_shm_path).is_err());
509 }
510
511 /// Assert that the reader will return an error when it tries to read a file
512 /// that has a segement size that is too small to fit the VMClockShmHeader.
513 #[test]
514 fn test_reader_segment_size_smaller_than_header() {
515 let vmclock_shm_tempfile = NamedTempFile::new().expect("create vmclock file failed");

Callers

nothing calls this directly

Calls 3

write_vmclock_contentFunction · 0.70
newFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected