toybox/tests/rmdir.test
<<
>>
Prefs
   1#!/bin/bash
   2
   3[ -f testing.sh ] && . testing.sh
   4
   5#testing "name" "command" "result" "infile" "stdin"
   6
   7mkdir one
   8testing "rmdir" "rmdir one && [ ! -d one ] && echo yes" "yes\n" "" ""
   9
  10touch walrus
  11testing "file" \
  12        "rmdir walrus 2> /dev/null || [ -f walrus ] && echo yes" "yes\n" "" ""
  13
  14mkdir one two
  15testing "one two" \
  16        "rmdir one two 2> /dev/null && [ ! -d one ] && [ ! -d two ] && echo yes" \
  17        "yes\n" "" ""
  18
  19mkdir one two three
  20testing "one missing two file three" \
  21        "rmdir one missing two walrus three 2> /dev/null || [ ! -d three ] && echo yes" \
  22        "yes\n" "" ""
  23rm walrus
  24
  25mkdir one
  26chmod 000 one
  27testing "mode 000" "rmdir one && [ ! -d one ] && echo yes" "yes\n" "" ""
  28
  29mkdir temp
  30touch temp/thing
  31testing "non-empty" \
  32        "rmdir temp 2>/dev/null || [ -d temp ] && echo yes" "yes\n" "" ""
  33testing "-p dir/file" \
  34        "rmdir -p temp/thing 2>/dev/null || [ -f temp/thing ] && echo yes" \
  35        "yes\n" "" ""
  36
  37mkdir -p temp/one/two/three
  38testing "-p part of path" \
  39        "rmdir -p temp/one/two/three 2>/dev/null || [ -d temp ] && [ ! -e temp/one ] && echo yes" \
  40        "yes\n" "" ""
  41rm -rf temp
  42
  43skipnot [ $UID -eq 0 ]
  44testing '-p abspath' \
  45  'mkdir -p /test/2/3 && rmdir -p /test/2/3 && [ ! -e /test ] && echo yes' \
  46  'yes\n' '' ''
  47
  48mkdir -p one/two/three
  49testing "-p one/two/three" \
  50        "rmdir -p one/two/three && [ ! -e one ] && echo yes" "yes\n" "" ""
  51
  52mkdir -p one/two/three
  53testing "-p one/two/three/" \
  54        "rmdir -p one/two/three/ && [ ! -e one ] && echo yes" "yes\n" "" ""
  55
  56#mkdir -p one/two/three
  57#chmod 000 one/two/three one/two one
  58#testing "-p one/two/three" \
  59#       "rmdir -p one/two/three && [ ! -e one ] && echo yes" "yes\n" "" ""
  60