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# Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz> 5f08c3bdfSopenharmony_ci# Author: Manoj Iyer <manjo@mail.utexas.edu> 6f08c3bdfSopenharmony_ci# 7f08c3bdfSopenharmony_ci# Basic test for ln 8f08c3bdfSopenharmony_ci 9f08c3bdfSopenharmony_ciTST_CNT=6 10f08c3bdfSopenharmony_ciTST_TESTFUNC=do_test 11f08c3bdfSopenharmony_ciTST_SETUP=setup 12f08c3bdfSopenharmony_ciTST_NEEDS_TMPDIR=1 13f08c3bdfSopenharmony_ci 14f08c3bdfSopenharmony_cisetup() 15f08c3bdfSopenharmony_ci{ 16f08c3bdfSopenharmony_ci ROD mkdir -p dir/subdir 17f08c3bdfSopenharmony_ci ROD echo "LTP" > file 18f08c3bdfSopenharmony_ci ROD touch dir/file 19f08c3bdfSopenharmony_ci} 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_cicheck_dir_link() 22f08c3bdfSopenharmony_ci{ 23f08c3bdfSopenharmony_ci local dname="$1" 24f08c3bdfSopenharmony_ci local lname="$2" 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ci ROD ls "$lname" > lname.out 27f08c3bdfSopenharmony_ci ROD ls "$dname" > dname.out 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ci if diff lname.out dname.out; then 30f08c3bdfSopenharmony_ci tst_res TPASS "Directory and link content is equal" 31f08c3bdfSopenharmony_ci else 32f08c3bdfSopenharmony_ci tst_res TFAIL "Directory and link content differs" 33f08c3bdfSopenharmony_ci cat lname.out 34f08c3bdfSopenharmony_ci echo 35f08c3bdfSopenharmony_ci cat dname.out 36f08c3bdfSopenharmony_ci fi 37f08c3bdfSopenharmony_ci} 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_cicheck_file_link() 40f08c3bdfSopenharmony_ci{ 41f08c3bdfSopenharmony_ci local fname="$1" 42f08c3bdfSopenharmony_ci local lname="$2" 43f08c3bdfSopenharmony_ci 44f08c3bdfSopenharmony_ci if diff $fname $lname; then 45f08c3bdfSopenharmony_ci tst_res TPASS "File and link content is equal" 46f08c3bdfSopenharmony_ci else 47f08c3bdfSopenharmony_ci tst_res TFAIL "File and link content differs" 48f08c3bdfSopenharmony_ci fi 49f08c3bdfSopenharmony_ci} 50f08c3bdfSopenharmony_ci 51f08c3bdfSopenharmony_ciln_test() 52f08c3bdfSopenharmony_ci{ 53f08c3bdfSopenharmony_ci local args="$1" 54f08c3bdfSopenharmony_ci local src="$2" 55f08c3bdfSopenharmony_ci local link="$3" 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_ci EXPECT_PASS ln $args $src $link 58f08c3bdfSopenharmony_ci 59f08c3bdfSopenharmony_ci if [ -f $src ]; then 60f08c3bdfSopenharmony_ci check_file_link $src $link 61f08c3bdfSopenharmony_ci else 62f08c3bdfSopenharmony_ci check_dir_link $src $link 63f08c3bdfSopenharmony_ci fi 64f08c3bdfSopenharmony_ci 65f08c3bdfSopenharmony_ci ROD rm $link 66f08c3bdfSopenharmony_ci} 67f08c3bdfSopenharmony_ci 68f08c3bdfSopenharmony_cido_test() 69f08c3bdfSopenharmony_ci{ 70f08c3bdfSopenharmony_ci case $1 in 71f08c3bdfSopenharmony_ci 1) ln_test "" "file" "file_link";; 72f08c3bdfSopenharmony_ci 2) ln_test "-s" "file" "file_link";; 73f08c3bdfSopenharmony_ci 3) ln_test "-s" "dir" "dir_link";; 74f08c3bdfSopenharmony_ci 4) ln_test "" "$PWD/file" "file_link";; 75f08c3bdfSopenharmony_ci 5) ln_test "-s" "$PWD/file" "file_link";; 76f08c3bdfSopenharmony_ci 6) ln_test "-s" "$PWD/dir" "dir_link";; 77f08c3bdfSopenharmony_ci esac 78f08c3bdfSopenharmony_ci} 79f08c3bdfSopenharmony_ci 80f08c3bdfSopenharmony_ci. tst_test.sh 81f08c3bdfSopenharmony_citst_run 82