Skip to content

Commit

Permalink
Add basic implementation of abandoning parent test
Browse files Browse the repository at this point in the history
Just check that we have the correct number of processes

Fixes #44
  • Loading branch information
asmacdo committed Jan 14, 2025
1 parent f0035e4 commit fa434d8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/test_e2e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from __future__ import annotations
import json
from pathlib import Path
import subprocess

ABANDONING_PARENT = str(Path(__file__).with_name("data") / "abandoning_parent.sh")


def test_sanity(temp_output_dir: str) -> None:
command = f"duct -p {temp_output_dir}log_ sleep 0.1"
subprocess.check_output(command, shell=True)


def test_abandoning_parent(temp_output_dir: str) -> None:
duct_prefix = f"{temp_output_dir}log_"
num_children = 3
command = f"duct -p {duct_prefix} {ABANDONING_PARENT} {num_children} sleep 0.1"
subprocess.check_output(command, shell=True)

with open(f"{duct_prefix}usage.json") as usage_file:
all_samples = [json.loads(line) for line in usage_file]

max_processes_sample = {"processes": {}}
for sample in all_samples:
if len(max_processes_sample) < len(sample.get("processes")):
max_processes_sample = sample

# 1 for each child, 1 for pstree, 1 for parent
assert len(max_processes_sample) == num_children + 2

0 comments on commit fa434d8

Please sign in to comment.