1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) Linux Test Project, 2002-2022 4# Copyright (c) 2016-2018 Oracle and/or its affiliates. All Rights Reserved. 5# Copyright (c) International Business Machines Corp., 2001 6# 7# PURPOSE: 8# Two processes open FLOCK_IDATA file simultaneously 9# each one locks odd and even lines of the file simultaneously 10# and fill them with '0's and '1's. After they find eof, the 11# datafiles are compared. 12 13TST_SETUP="do_setup" 14TST_TESTFUNC="do_test" 15 16do_setup() 17{ 18 nfs_setup 19 20 tst_res TINFO "creating test files" 21 ROD nfs_flock_dgen flock_data 63 16384 0 22 ROD nfs_flock_dgen flock_odata 63 16384 1 23 24 [ "$(wc -c flock_data | awk '{print $1}')" -ne 1048576 ] && \ 25 tst_brk TBROK "could not create 'flock_data'" 26 27 [ "$(wc -c flock_odata | awk '{print $1}')" -ne 1048576 ] && \ 28 tst_brk TBROK "could not create 'flock_odata'" 29} 30 31do_test() 32{ 33 tst_res TINFO "Testing locking" 34 35 ROD cp flock_data flock_idata 36 37 tst_res TINFO "locking 'flock_idata' file and writing data" 38 39 nfs_flock 0 flock_idata & 40 local pids=$! 41 nfs_flock 1 flock_idata & 42 pids="$pids $!" 43 44 tst_res TINFO "waiting for pids: $pids" 45 for p in $pids; do 46 wait $p 47 if [ $? -ne 0 ]; then 48 tst_brk TFAIL "nfs_lock process failed" 49 else 50 tst_res TINFO "$p completed" 51 fi 52 done 53 54 diff flock_odata flock_idata 55 if [ $? -ne 0 ]; then 56 tst_res TFAIL "content is different" 57 else 58 tst_res TPASS "content is the same" 59 fi 60} 61 62. nfs_lib.sh 63tst_run 64