Skip to content

Instantly share code, notes, and snippets.

@netj
Created March 18, 2016 19:43
Show Gist options
  • Save netj/8f7e2e73f3913d12703e to your computer and use it in GitHub Desktop.
Save netj/8f7e2e73f3913d12703e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bats
# an attempt to test https://github.com/netj/mkmimo against cases where read(2)/write(2) returns error
load test_helpers
@test "exits with non-zero status with bad files" {
rm -fv non-existent-input non-existent-output
! mkmimo non-existent-input \> >non-existent-output || false
! mkmimo <non-existent-input \> non-existent-output || false
}
@test "exits with non-zero status when an input goes wrong" {
mkprocs -n 1 -O inputs-normal.%s yes "$(random_records 4096~2048 10)"
# FIXME can't make this generate read(2) error in mkmimo side
mkprocs -n 2 -O inputs-selfdestruction.%s bash -c 'timeout -s QUIT 1.$RANDOM yes'
timeout 3s bash -c '! mkmimo inputs-* \> /dev/null || false'
}
@test "exits with non-zero status when an output goes wrong" {
n=10000
mkprocs -n 1 -O outputs-normal.%s dd of=/dev/null
# FIXME can't make this generate read(2) error in mkmimo side
mkprocs -n 2 -O outputs-selfdestruction.%s bash -c 'head >/dev/null; date; sleep 1.$RANDOM; date; kill -KILL $$'
# mkmimo should return non-zero exit status here and stop early
timeout 3s bash -c '! mkmimo <(yes "$(random_records 4096~2048 10)") \> outputs-* || false'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment