1f08c3bdfSopenharmony_ci#!/bin/sh
2f08c3bdfSopenharmony_ci################################################################################
3f08c3bdfSopenharmony_ci##                                                                            ##
4f08c3bdfSopenharmony_ci## Copyright (c) International Business Machines  Corp., 2008                 ##
5f08c3bdfSopenharmony_ci##                                                                            ##
6f08c3bdfSopenharmony_ci## This program is free software;  you can redistribute it and#or modify      ##
7f08c3bdfSopenharmony_ci## it under the terms of the GNU General Public License as published by       ##
8f08c3bdfSopenharmony_ci## the Free Software Foundation; either version 2 of the License, or          ##
9f08c3bdfSopenharmony_ci## (at your option) any later version.                                        ##
10f08c3bdfSopenharmony_ci##                                                                            ##
11f08c3bdfSopenharmony_ci## This program is distributed in the hope that it will be useful, but        ##
12f08c3bdfSopenharmony_ci## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
13f08c3bdfSopenharmony_ci## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
14f08c3bdfSopenharmony_ci## for more details.                                                          ##
15f08c3bdfSopenharmony_ci##                                                                            ##
16f08c3bdfSopenharmony_ci## You should have received a copy of the GNU General Public License          ##
17f08c3bdfSopenharmony_ci## along with this program;  if not, write to the Free Software               ##
18f08c3bdfSopenharmony_ci## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
19f08c3bdfSopenharmony_ci##                                                                            ##
20f08c3bdfSopenharmony_ci################################################################################
21f08c3bdfSopenharmony_ci
22f08c3bdfSopenharmony_ciexport TCID=ioctl01_02
23f08c3bdfSopenharmony_ciexport TST_TOTAL=2
24f08c3bdfSopenharmony_ciexport TST_COUNT=0
25f08c3bdfSopenharmony_ci
26f08c3bdfSopenharmony_cihas_tty()
27f08c3bdfSopenharmony_ci{
28f08c3bdfSopenharmony_ci    if command -v stty >/dev/null 2>&1; then
29f08c3bdfSopenharmony_ci        stty -F $1 > /dev/null
30f08c3bdfSopenharmony_ci        if [ $? -ne 0 ]; then
31f08c3bdfSopenharmony_ci            return 0
32f08c3bdfSopenharmony_ci        fi
33f08c3bdfSopenharmony_ci    fi
34f08c3bdfSopenharmony_ci    return 1
35f08c3bdfSopenharmony_ci}
36f08c3bdfSopenharmony_ci
37f08c3bdfSopenharmony_cifor tttype in `ls /dev/tty*`
38f08c3bdfSopenharmony_cido
39f08c3bdfSopenharmony_cidevice_no=${tttype#/dev/tty}
40f08c3bdfSopenharmony_cicase "$device_no" in
41f08c3bdfSopenharmony_ci[0-9]|[0-9][0-9])
42f08c3bdfSopenharmony_ci    has_tty $tttype
43f08c3bdfSopenharmony_ci    if [ $? -eq 0 ]; then
44f08c3bdfSopenharmony_ci        tst_resm TINFO "Skipping ioctl02 with $tttype"
45f08c3bdfSopenharmony_ci        continue
46f08c3bdfSopenharmony_ci    fi
47f08c3bdfSopenharmony_ci    tst_resm TINFO "Testing ioctl02 with $tttype"
48f08c3bdfSopenharmony_ci    ioctl02 -D $tttype
49f08c3bdfSopenharmony_ci    RC=$?
50f08c3bdfSopenharmony_ci    if  [ $RC -eq 0 ]
51f08c3bdfSopenharmony_ci    then
52f08c3bdfSopenharmony_ci     tst_resm TPASS "ioctl02 Passed with $tttype"
53f08c3bdfSopenharmony_ci    else
54f08c3bdfSopenharmony_ci     tst_resm TFAIL "ioctl02 Failed with $tttype"
55f08c3bdfSopenharmony_ci    fi
56f08c3bdfSopenharmony_ciecho;;
57f08c3bdfSopenharmony_ciesac
58f08c3bdfSopenharmony_cidone
59f08c3bdfSopenharmony_citst_exit
60f08c3bdfSopenharmony_ci
61