warning: in the working copy of 'tools/omp-spt/tests/echo_commune_omp.rs', LF will be replaced by CRLF the next time Git touches it
diff --git a/tools/omp-spt/tests/echo_commune_omp.rs b/tools/omp-spt/tests/echo_commune_omp.rs
new file mode 100644
index 0000000..6ad81af
--- /dev/null
+++ b/tools/omp-spt/tests/echo_commune_omp.rs
@@ -0,0 +1,67 @@
+use std::io::Write;
+use std::path::{Path, PathBuf};
+use std::process::{Command, Output, Stdio};
+use std::sync::atomic::{AtomicU64, Ordering};
+
+const EMPTY_DELTA: &[u8] = b"";
+
+struct TempRoot(PathBuf);
+
+impl TempRoot {
+ fn new() -> Self {
+ static NEXT: AtomicU64 = AtomicU64::new(0);
+ let path = std::env::temp_dir().join(format!(
+ "omp-spt-echo-empty-int-{}-{}",
+ std::process::id(),
+ NEXT.fetch_add(1, Ordering::Relaxed)
+ ));
+ std::fs::create_dir_all(&path).unwrap();
+ Self(path)
+ }
+}
+
+impl Drop for TempRoot {
+ fn drop(&mut self) {
+ let _ = std::fs::remove_dir_all(&self.0);
+ }
+}
+
+fn run_echo(input: &[u8], session_dir: &Path, missing_omp: &Path) -> Output {
+ let mut child = Command::new(env!("CARGO_BIN_EXE_omp-spt"))
+ .args([
+ "echo-commune-omp",
+ "--id",
+ "empty-tail-test",
+ "--session-id",
+ "not-present",
+ "--session-dir",
+ ])
+ .arg(session_dir)
+ .env("OMP_SPT_OMP_BIN", missing_omp)
+ .stdin(Stdio::piped())
+ .stdout(Stdio::piped())
+ .stderr(Stdio::piped())
+ .spawn()
+ .unwrap();
+ child.stdin.take().unwrap().write_all(input).unwrap();
+ child.wait_with_output().unwrap()
+}
+
+// [int->REQ-SESSION-ECHO-COMMUNE]
+#[test]
+fn empty_whitespace_and_giant_single_line_tails_emit_empty_delta_without_resolving_omp() {
+ let tmp = TempRoot::new();
+ let missing_omp = tmp.0.join("must-not-spawn-omp");
+ let giant = vec![b'x'; 48 * 1024 + 1];
+
+ for input in [b"".as_slice(), b" \t\r\n".as_slice(), giant.as_slice()] {
+ let output = run_echo(input, &tmp.0, &missing_omp);
+ assert!(
+ output.status.success(),
+ "echo stderr: {}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+ assert_eq!(output.stdout, EMPTY_DELTA);
+ assert!(output.stderr.is_empty());
+ }
+}