1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # ident "@(#)utils_common.ksh 1.9 09/08/16 SMI"
27 #
28
29 #
30 # This file contains common functions that are used to manage the
31 # test cases and other functionality in the test suite that would
32 # be a utility type function. The start and cleanup functions for
33 # example.
34 #
35
36 #
37 # NAME
38 # clean_logs
39 #
40 # DESCRIPTION
41 # Clean up the default known log files.
42 #
43 function clean_logs {
44 if [ $s_log ]
45 then
46 $RM -f ${s_log}* > /dev/null 2>&1
47 fi
48 if [ $l_log ]
49 then
50 $RM -f ${l_log}* > /dev/null 2>&1
51 fi
52 if [ $dfs_log ]
53 then
54 $RM -f ${dfs_log}* > /dev/null 2>&1
55 fi
56 }
57
58 #
59 # NAME
60 # cancel_tests
61 #
62 # DESCRIPTION
63 # Cancel all the test purposes
64 #
65 function cancel_tests {
66 for ct_TestCase in $iclist
67 do
68 eval ct_TestPurp=\${$ct_TestCase}
69 tet_infoline "tet_delete $ct_TestPurp"
70 tet_delete $ct_TestPurp \
71 "Canceling all tests : see previous log entries"
72 done
73 }
74
75 #
76 # NAME
77 # build_fs
78 #
79 # DESCRIPTION
80 # Build the file systems and mount file systems according to
81 # configuration parameters.
82 # - Create all the directories that are needed.
83 # - Check the devices are not in use
84 # - Create the needed file systems (ufs and/or zfs)
85 # - Mount the file systems
86 #
87 function build_fs {
88 typeset -i i=0
89 tet_infoline "create the needed directories"
90 for i in 0 1 2 3 4
91 do
92 if [ -d ${MP[$i]} ]
93 then
94 tet_infoline "Test ${MP[$i]} directory already exists "
95 cancel_tests
96 return 1
97 fi
98 $MKDIR -p ${MP[$i]}
99 if [ $? -ne 0 ]
100 then
101 cti_result UNRESOLVED \
102 "Cannot create the directory ${MP[$i]}"
103 cancel_tests
104 return 1
105 fi
106 done
107 #
108 # Mixed configuration, half ufs and half zfs
109 # If the TESTDIR is based on UFS, create test file systems from the new
110 # created zpool, otherwise, create all file systems from the existing zpool
111 #
112 typeset zfspool="share_pool"
113 [[ -n $ZFSPOOL ]] && zfspool=$ZFSPOOL
114 for i in 0 2; do
115 create_ufs_fs $zfspool ${MP[$i]} 256m
116 if (( $? != 0 )); then
117 cti_result UNRESOLVED "failed to create ufs<${MP[$i]}>"
118 cancel_tests
119 return 1
120 fi
121 done
122 i=1
123 for size in "512m" "1g"; do
124 create_zfs_fs $zfspool ${MP[$i]} $size
125 if (( $? != 0 )); then
126 cti_result UNRESOLVED "failed to create zfs<${MP[$i]}>"
127 cancel_tests
128 return 1
129 fi
130 i=$((i + 2))
131 done
132
133 return 0
134 }
135
136 #
137 # NAME
138 # share_startup
139 #
140 # DESCRIPTION
141 # The common startup function used at the beginning of each
142 # sub-suite.
143 # - Unset all the common variables.
144 # - Verify that the sharemgr binary exists
145 # - Verify that the legacy share tests need to be done
146 # - Setup the basic log directory and files.
147 # - Check and capture current shares on the system
148 # - Call build_fs to setup the file systems
149 #
150 function share_startup {
151 REBOOT_STARTUP=$1
152
153 #
154 # Do not let the startup phase be trapped
155 #
156 TRAPCOT=0
157 trap TRAPCOT=1 2 15 EXIT
158
159 #
160 # Reset the umask to 022 this is a temporary fix to the
161 # bug_018. This will be removed once the smf/rbac bits
162 # are done and the tmp file will go away that is causing
163 # this issue.
164 #
165 umask 022
166
167
168 unset real_shares
169 unset cmd_prefix
170 unset cmd_postfix
171 unset cmd_prepost_lock
172 tet_infoline "checkenv for runability"
173 #
174 # Leaving this for now to get a bit more information
175 # on the checkenv tool and figure out a bit more about
176 # using it.
177 #
178
179 tet_infoline "check for the new sharemgr commands"
180 if [ "$report_only" = "TRUE" -o -x /usr/sbin/sharemgr ]
181 then
182 SHAREMGR=/usr/sbin/sharemgr
183 else
184 #
185 # Not installed in the default need to look in the
186 # var sadm contents to see if we can find it.
187 # Otherwise ABORT
188 #
189 tet_infoline "Share Manager tool is not installed, aborting"
190 tet_result UNSUPPORTED
191 cancel_tests
192 return 1
193 fi
194
195 tet_infoline "check for the new sharectl commands"
196 if [ "$report_only" = "TRUE" -o -x /usr/sbin/sharectl ]
197 then
198 SHARECTL=/usr/sbin/sharectl
199 else
200 #
201 # Not installed in the default need to look in the
202 # var sadm contents to see if we can find it.
203 # Otherwise ABORT
204 #
205 tet_infoline "Share CTL tool is not installed, aborting"
206 tet_result UNSUPPORTED
207 cancel_tests
208 return 1
209 fi
210
211 tet_infoline "check for legacy share"
212 if [ "$report_only" = "TRUE" -o -x /usr/sbin/share ]
213 then
214 LEGACYSHARE=/usr/sbin/share
215 LEGACYUNSHARE=/usr/sbin/unshare
216 else
217 LEGACYSHARE=""
218 fi
219
220 if [ "$report_only" = "TRUE" ]
221 then
222 [ ! $CMD_SUMMARY_FILE ] && \
223 CMD_SUMMARY_FILE=$SHR_TMPDIR/sharemgr_cmd_summary.$$
224 return 0
225 fi
226
227 if [ ! -d $LOGDIR ]
228 then
229 $MKDIR -p $LOGDIR
230 if [ $? -ne 0 ]
231 then
232 #
233 # No logging can occur therefor all verifications
234 # are going to fail.
235 #
236 cancel_tests
237 return 1
238 fi
239 else
240 #
241 # Clean out log files
242 #
243 clean_logs
244 fi
245
246 if [ "$REBOOT_STARTUP" ]
247 then
248 tet_infoline "Skipping the rest of startup due to reboot test."
249 trap 2 15 EXIT
250 return 0
251 fi
252
253 #
254 # Check for test_groups in use
255 #
256 TGPTR=0
257 TGFND=0
258 while [ $TGPTR -lt ${#TG[*]} ]
259 do
260 sharemgr list | $GREP ${TG[$TGPTR]}
261 if [ $? -eq 0 ]
262 then
263 tet_infoline "${TG[$TGPTR]} is listed in sharemgr list"
264 tet_result UNRESOLVED
265 TGFND=`$EXPR $TGFND + 1`
266 else
267 set -A ShTstTG ${ShTstTG[*]} ${TG[$TGPTR]}
268 fi
269 TGPTR=`$EXPR $TGPTR + 1`
270 done
271 if [ $TGFND -gt 0 ]
272 then
273 cancel_tests
274 return 1
275 fi
276
277 #
278 # Make an attempt to see if there are any groups already setup.
279 #
280 real_shares=`$SHAREMGR list`
281 tet_infoline "real_share = $real_shares"
282
283 #
284 # Update the /etc/nfs/nfslog.conf file with entries required
285 # some of the tests.
286 #
287 cp /etc/nfs/nfslog.conf /etc/nfs/nfslog.sharemgr_tests.orig
288 echo "nfslog de4faultdir=/var/tmp \\" >> /etc/nfs/nfslog.conf
289 echo " log=nfslog fhtable=fhtable buffer=nfslog_workbuffer" \
290 >> /etc/nfs/nfslog.conf
291 echo "true de4faultdir=/var/tmp \\" >> /etc/nfs/nfslog.conf
292 echo " log=nfslog fhtable=fhtable buffer=nfslog_workbuffer" \
293 >> /etc/nfs/nfslog.conf
294
295 #
296 # Determine the default protocols to be used during testing.
297 #
298 unset def_protocols
299 def_protocols=`sharectl status | grep -v client | awk '{printf("%s ", $1)}'`
300 tet_infoline "The default protocols are $def_protocols"
301
302 if [ "$setup_once" != "TRUE" ]; then
303 build_fs
304 [ $? -ne 0 ] && return 1
305 fi
306
307 if [ $TRAPCOT -eq 1 ]
308 then
309 tet_infoline "trap caught in startup phase"
310 #
311 # Wait for children to complete and then cleanup
312 #
313 wait
314 sleep 1
315 wait
316 tet_infoline "Calling share_cleanup"
317 share_cleanup
318 exit
319 fi
320 trap 2 15 EXIT
321
322 return 0
323 }
324
325 #
326 # NAME
327 # clean_fs
328 #
329 # DESCRIPTION
330 # clean the file systems that were created for the tests by
331 # unmounting and tearing down the zfs file systems and pools
332 # that were created.
333 #
334 function clean_fs {
335 for i in 0 2; do
336 destroy_ufs_fs ${MP[$i]}
337 (( $? != 0 )) && \
338 tet_infoline "WARNING, unable to destroy ufs<${MP[$i]}>"
339 done
340
341 for i in 1 3; do
342 typeset ZFSn=$(zfs list -o mountpoint,name \
343 | grep "^${MP[$i]}" | awk '{print $2}')
344 if (( $? == 0 )) && [[ -n $ZFSn ]]; then
345 zfs destroy -r -f $ZFSn
346 (( $? != 0 )) && \
347 tet_infoline \
348 "WARNING, unable to destroy zfs <${MP[$i]}>"
349 fi
350 done
351
352 #
353 # Remove the td directories
354 #
355 for i in 0 1 2 3 4
356 do
357 if [ -d ${MP[$i]} ]
358 then
359 $RMDIR ${MP[$i]}
360 if [ $? -ne 0 ]
361 then
362 #
363 # The directory may have been mounted but not
364 # added to the mount list due to interrupt or
365 # some other error. If the directory is in
366 # this list then it is safe to attempt to
367 # unmount the directory here just to make sure
368 # this is the reason for the failure.
369 #
370 $UMOUNT -f ${MP[$i]}
371 $RMDIR ${MP[$i]}
372 if [ $? -ne 0 ]
373 then
374 tet_infoline "Unable to remove ${MP[$i]}"
375 fi
376 fi
377 fi
378 done
379
380 if [ -d ${TESTDIR} ]
381 then
382 $RM -fr ${TESTDIR}/td*
383 fi
384 }
385
386 #
387 # NAME: delete_all_test_groups
388 #
389 # SYNOPSIS: delete_all_test_groups
390 #
391 # DESCRIPTION:
392 # This function deletes all groups created by the test suit. As the
393 # list of groups maintained by the tests ($GROUPS) may not always be
394 # 100% correct (if the 'sharemgr create' command misbehaves), we prefer
395 # to delete all groups that the 'sharemgr list' command says are
396 # configured. Exceptions are 'default' and 'zfs' which are always
397 # present on the system.
398 #
399 # We will fall back to deleting groups based on $GROUPS only if we are
400 # unable to retrieve a list of groups from 'sharemgr list'.
401 #
402 function delete_all_test_groups {
403
404 datg_listed_groups=`$SHAREMGR list`
405 if [ "$datg_listed_groups" ]
406 then
407 #
408 # 'sharemgr list' returned a list of configured groups. Delete
409 # all of the groups in that list except 'default' and 'zfs'.
410 #
411 for datg_listed_group in $datg_listed_groups
412 do
413 #
414 # Skip the groups that are always configured on the
415 # system ('default' and 'zfs')
416 #
417 if [ "$datg_listed_group" = "default" -o \
418 "$datg_listed_group" = "zfs" ]
419 then
420 continue
421 fi
422
423 #
424 # Skip the shares that were defined on the system
425 # at the start of the tests.
426 #
427 echo "$real_shares" | grep "$datg_listed_group" > /dev/null
428 if [ $? -eq 0 ]
429 then
430 continue
431 fi
432
433 #
434 # Determine if the group we are about to delete is one
435 # that we expected to be configured.
436 #
437 unset datg_expected
438 for datg_indicated_group in $GROUPS
439 do
440 if [ "$datg_indicated_group" = \
441 "$datg_listed_group" ]
442 then
443 datg_expected=yes
444 break
445 fi
446 done
447 if [ ! "$datg_expected" ]
448 then
449 tet_infoline "WARNING: 'sharemgr list' shows" \
450 "group $datg_listed_group that the tests" \
451 "don't think is currently configured"
452 fi
453
454 #
455 # Actually perform the delete
456 #
457 delete NO_RESULT_CHK POS $datg_listed_group -f
458 done
459 else
460 #
461 # 'sharemgr list' did not return a list of groups, which
462 # probably means the command itself failed. In that case,
463 # delete any groups that the test cases had recorded as
464 # having created.
465 #
466 for datg_group in $GROUPS
467 do
468 delete NO_RESULT_CHK POS $datg_group -f
469 done
470 fi
471 }
472
473 #
474 # NAME
475 # share_cleanup
476 #
477 # DESCRIPTION
478 # The common cleanup function used at the end of each
479 # sub-suite.
480 # - Call clean_fs() to clean up the file systems
481 # - re-enable any shares that were originally shared on the fs.
482 # - Remove any groups that might have been left over.
483 # - cleanup the default logs.
484 #
485 function share_cleanup {
486 if [ "$report_only" = "TRUE" ]
487 then
488 return
489 fi
490
491 [ "$setup_once" != "TRUE" ] && clean_fs
492
493 #
494 # If found groups on startup make sure all groups are re-enabled.
495 #
496 if [ "$real_shares" ]
497 then
498 tet_infoline "re-enable real groups - $SHAREMGR enable -a"
499 $SHAREMGR enable -a
500 fi
501
502 #
503 # Remove any groups that may have been created but got
504 # left behind.
505 #
506 for ShGrp in ${ShTstTG[*]}
507 do
508 $SHAREMGR list | $GREP -w $ShGrp > /dev/null 2>&1
509 if [ $? -eq 0 ]
510 then
511 $SHAREMGR delete -f $ShGrp
512 fi
513 done
514
515 #
516 # Put the nfslog.conf file back in place.
517 #
518 mv /etc/nfs/nfslog.sharemgr_tests.orig /etc/nfs/nfslog.conf > \
519 /dev/null 2>&1
520
521 #
522 # Remove any left over log files
523 #
524 clean_logs
525 $RM -fr ${LOGDIR} > /dev/null 2>&1
526 }
527
528 #
529 # NAME
530 # reset_paths
531 #
532 # DESCRIPTION
533 # Simply attempt to reset all the file system paths and delete
534 # any groups, in an attempt to recover from a minor failure.
535 #
536 # Clear out all the mount points and then remount them.
537 # Make sure to destroy all shares that potentially are left
538 # about.
539 # Then recreate all the paths and remount all the devices.
540 #
541 # Any failure here will be considered catastrophic because this
542 # function is called to put a bad state back to a good state, and
543 # we do not want to work from a bad state.
544 #
545 function reset_paths {
546 delete_all_test_groups
547
548 clean_fs
549
550 build_fs
551 }
552
553 #
554 # NAME
555 # infofile
556 #
557 # DESCRIPTION
558 # Write a file out using tet_infoline
559 #
560 function infofile {
561 i_prefix=$1
562
563 while read i_line
564 do
565 tet_infoline "$i_prefix$i_line"
566 done < $2
567 }
568
569 #
570 # NAME
571 # check_for_core
572 #
573 # DESCRIPTION
574 # Check for the potential catastrophic failure of the command based
575 # on the result.
576 #
577 function check_for_core {
578 if [ $1 -ge 131 ]
579 then
580 tet_infoline "Core dump likely produced!"
581 fi
582 }
583
584 #
585 # NAME
586 # POS_results
587 #
588 # DESCRIPTION:
589 # Evaluate the results of a command that was expected return status of
590 # zero. If the command did not return status of zero print a
591 # failure line to the journal containing fail_string, set tet_result
592 # to FAIL.
593 #
594 # $1 result to check
595 # $2 ($3) "FAIL string output"
596 # $3 ($4) "PASS string output"
597 #
598 function POS_result {
599 if [ "$report_only" = "TRUE" ]
600 then
601 return 0
602 fi
603
604 Pr_result=$1
605 #
606 # Check to see if $2 was a string or a value.
607 # This means that the fail string must begin with an alpha
608 # character a-z or A-Z in order to be detected by the following
609 # statement.
610 #
611 if [ `$EXPR "$2" : '.*/.*'` -gt 0 -o \
612 `$EXPR "$2" : .*[a-z].*` -gt 0 -o \
613 `$EXPR "$2" : .*[A-Z].*` -gt 0 ]
614 then
615 Pr_fail_str=$2
616 else
617 Pr_fail_str=$3
618 shift
619 fi
620
621 if [ ! "$3" ]
622 then
623 Pr_pass_str=$2
624 else
625 Pr_pass_str=$3
626 fi
627
628 # Verify return code is 0"
629 if [ $Pr_result -ne 0 ]
630 then
631 eval tet_infoline \"FAIL - $Pr_fail_str\"
632 check_for_core $Pr_result
633 if [ "$logfile" -a -f "$logfile" ]
634 then
635 infofile "" $logfile
636 fi
637 tet_result FAIL
638 elif [ "$verbose" = "True" ]
639 then
640 eval tet_infoline \"PASS - $Pr_pass_str\"
641 fi
642
643 return $Pr_result
644 }
645
646 #
647 # NAME
648 # NEG_results
649 #
650 # DESCRIPTION:
651 # Evaluate the results of a command that was expected return non-zero
652 # status. If the command did not return non-zero status print a
653 # failure line to the journal containing fail_string, set tet_result
654 # to FAIL.
655 #
656 # $1 result to check
657 # $2 ($3) "string output"
658 # $3 ($4) "PASS string output"
659 #
660 function NEG_result {
661 if [ "$report_only" = "TRUE" ]
662 then
663 return
664 fi
665
666 Nr_result=$1
667
668 #
669 # Check to see if $2 was a string or a value.
670 # This means that the fail string must begin with an alpha
671 # character a-z or A-Z in order to be detected by the following
672 # statement.
673 #
674 if [ `$EXPR "$2" : '.*/.*'` -gt 0 -o \
675 `$EXPR "$2" : .*[a-z].*` -gt 0 -o \
676 `$EXPR "$2" : .*[A-Z].*` -gt 0 ]
677 then
678 Nr_fail_str=$2
679 else
680 Nr_fail_str=$3
681 shift
682 fi
683
684 if [ ! "$3" ]
685 then
686 Nr_pass_str=$2
687 else
688 Nr_pass_str=$3
689 fi
690
691 #
692 # Should check for core on NEG results just to make
693 # sure the reason for failure was not a core dump,
694 # because core dumps are bad.
695 #
696 check_for_core $Nr_result
697 if [ $? -ne 0 ]
698 then
699 tet_infoline "FAIL - command failed but possibly due to a corefile:"
700 eval tet_infoline \" $Nr_fail_str\"
701 tet_result FAIL
702 fi
703
704 # Verify return code is != 0"
705 if [ $Nr_result -eq 0 ]
706 then
707 tet_infoline "FAIL - command should have failed but succeeded:"
708 eval tet_infoline \" $Nr_fail_str\"
709 tet_result FAIL
710 elif [ "$verbose" = "True" ]
711 then
712 eval tet_infoline \"PASS - $Nr_pass_str\"
713 if [ "$logfile" ]
714 then
715 infofile "" $logfile
716 fi
717 fi
718
719 return $Nr_result
720 }
721
722 #
723 # NAME
724 # append_cmd
725 #
726 # DESCRIPTION
727 # Add the specified command to the list of commands executed by this
728 # test case.
729 #
730 function append_cmd {
731 if [ "$cmd_list" ]
732 then
733 cmd_list="$cmd_list\n $*"
734 else
735 cmd_list=" $*"
736 fi
737 #
738 # Unset the prefix and post fix as these should only be
739 # used for the primary command not any follow ups.
740 #
741 if [ ! $cmd_prepost_lock ]
742 then
743 unset cmd_prefix
744 unset cmd_postfix
745 fi
746 }
747
748
749 #
750 # NAME
751 # report_cmds
752 #
753 # DESCRIPTION
754 # Print out a summary of all commands executed by this test case.
755 #
756 function report_cmds {
757 rc_tc_id="$1" # ID for the current test case
758 rc_pos_or_neg="$2" # Is the test case positive (POS) or negative
759 # (NEG)?
760
761 if [ "$report_only" != "TRUE" -a "$verbose" != "TRUE" ]
762 then
763 return
764 fi
765
766 #
767 # Build a brief header for this test case description.
768 #
769 rc_header="----- $rc_tc_id $rc_pos_or_neg Relevant commands executed -----"
770 if [ "$CMD_SUMMARY_FILE" ]
771 then
772 # Send output to summary file
773 tet_infoline "Dumping commands to $CMD_SUMMARY_FILE"
774 echo $rc_header >> $CMD_SUMMARY_FILE
775 echo $cmd_list >> $CMD_SUMMARY_FILE
776 else
777 # Send output to standard out
778 tet_infoline $rc_header
779 tet_infoline $cmd_list
780 fi
781 }
782
783 #
784 # NAME
785 # get_logfile
786 #
787 # DESCRIPTION
788 # Calculate the appropriate log file used given a specific
789 # command and option set.
790 #
791 function get_logfile {
792 case $1 in
793 "list") shift
794 logfile=`echo ${l_log}$* | sed -e "s/ //g"`;;
795 "show") shift
796 logfile=`echo ${s_log}$* | sed -e "s/ //g"`;;
797 "dfsshare") shift
798 logfile=`echo ${dfs_log}$* | sed -e "s/ //g"`;;
799 *) logf=`echo sharemgr_$* | sed -e "s/ //g" | sed -e "s/\///g"`
800 logfile=${LOGDIR}/$logf;;
801
802 esac
803 echo $logfile
804 }
805
806 #
807 # NAME
808 # convertzfs
809 #
810 # DESCRIPTION
811 # Given a mount point convert to a zfs file system
812 #
813 function convertzfs {
814 $DF $1 | $AWK -F"(" '{print $2}' | $AWK -F")" '{print $1}'
815 }
816
817
818 #
819 # NAME
820 # add to vfstab
821 #
822 # DESCRIPTION
823 # Add the currently mounted ufs file systems to the vfstab
824 # to make them persistent across a reboot.
825 #
826 function addufstovfstab {
827 cp /etc/vfstab /etc/vfstab.sharemgr_tests.orig
828 if (( $? != 0 )); then
829 tet_infoline "Unable to save original vfstab, exiting"
830 tet_result UNRESOLVED
831 return 1
832 fi
833 for i in 0 2
834 do
835 typeset blockdev=$(df -k ${MP[$i]} | awk '{print $1}' | \
836 grep -v "^Filesystem$")
837 typeset fstype=$(fstyp $blockdev)
838 if [[ $fstype == ufs ]]; then
839 typeset rawdev=$(echo $blockdev | \
840 $SED 's/\/dsk\//\/rdsk\//')
841 echo "${blockdev}\t${rawdev}\t${MP[$i]}\tufs\t" \
842 "2\tno\trw" >> /etc/vfstab
843 fi
844 done
845 }
846
847 #
848 # NAME
849 # get_ctl_default
850 #
851 # DESCRIPTION
852 # Get the default value from the properties file.
853 #
854 function get_ctl_default {
855 gcd_property=$1
856
857 gcd_value=`$GREP -w $gcd_property $sharectl_orig | $AWK -F'=' '{print $2}'`
858
859 echo $gcd_value
860 }
861
862
863 #
864 # NAME
865 # check_ctl_support
866 #
867 # DESCRIPTION
868 # Check for each property provided there is support for the property
869 # to be used.
870 #
871 # RETURN VALUE
872 # Return 0 if supported and 1 if not supported.
873 #
874 function check_ctl_support {
875 ccs_property=$1
876
877 $GREP $ccs_property $sharectl_orig > /dev/null 2>&1
878 return $?
879 }
880
881 #
882 # NAME
883 # get_tet_result
884 #
885 # DESCRIPTION
886 # Look in the TET_TMPRES file and get the current result state.
887 # The current state is the last entry in this file.
888 #
889 # RETURN
890 # returns a blank if file doesn't exist
891 # returns the string PASS, FAIL, etc... of the current tet result
892 function get_tet_result {
893 if [ ! -f $TET_TMPRES ]
894 then
895 echo ""
896 return
897 fi
898
899 gtr_result=`tail -1 $TET_TMPRES`
900 echo $gtr_result
901 }
902
903 #
904 # NAME
905 # first
906 #
907 # DESCRIPTION
908 # Return first item in a list.
909 #
910 function first {
911 echo $1
912 }
913
914 #
915 # NAME
916 # rest
917 #
918 # DESCRIPTION
919 # Return all but the first item in a list.
920 #
921 function rest {
922 if [ "$1" ]
923 then
924 shift
925 fi
926
927 echo "$@"
928 }