• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) International Business Machines Corp., 2001
4# Author: Manoj Iyer <manjo@mail.utexas.edu>
5#
6# Basic mkdir tests
7
8TST_CNT=3
9TST_SETUP=setup
10TST_TESTFUNC=test
11TST_NEEDS_TMPDIR=1
12. tst_test.sh
13
14setup()
15{
16	ROD mkdir "dir"
17	LONG_PATH="some/long/path/of/several/directories"
18}
19
20test1()
21{
22	EXPECT_FAIL mkdir "dir" 2\> mkdir.out
23
24	if grep -q "dir.*File exists" mkdir.out; then
25		tst_res TPASS "Got correct error message"
26	else
27		tst_res TFAIL "Got wrong error message"
28		cat mkdir.out
29	fi
30}
31
32test2()
33{
34	EXPECT_FAIL mkdir "$LONG_PATH" 2\> mkdir.out
35
36	if grep -q "$LONG_PATH.*No such file or directory" mkdir.out; then
37		tst_res TPASS "Got correct error message"
38	else
39		tst_res TFAIL "Got wrong error message"
40		cat mkdir.out
41	fi
42
43	ROD rm -rf "$LONG_PATH"
44}
45
46test3()
47{
48	EXPECT_PASS mkdir -p "$LONG_PATH"
49
50	ROD rm -rf "$LONG_PATH"
51}
52
53tst_run
54