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