1*6cddff1aSabhinav# $NetBSD: t_uniq.sh,v 1.1 2016/10/22 14:13:39 abhinav Exp $ 2*6cddff1aSabhinav# 3*6cddff1aSabhinav# Copyright (c) 2016 The NetBSD Foundation, Inc. 4*6cddff1aSabhinav# All rights reserved. 5*6cddff1aSabhinav# 6*6cddff1aSabhinav# This code is derived from software contributed to The NetBSD Foundation 7*6cddff1aSabhinav# by Abhinav Upadhyay 8*6cddff1aSabhinav# 9*6cddff1aSabhinav# Redistribution and use in source and binary forms, with or without 10*6cddff1aSabhinav# modification, are permitted provided that the following conditions 11*6cddff1aSabhinav# are met: 12*6cddff1aSabhinav# 1. Redistributions of source code must retain the above copyright 13*6cddff1aSabhinav# notice, this list of conditions and the following disclaimer. 14*6cddff1aSabhinav# 2. Redistributions in binary form must reproduce the above copyright 15*6cddff1aSabhinav# notice, this list of conditions and the following disclaimer in the 16*6cddff1aSabhinav# documentation and/or other materials provided with the distribution. 17*6cddff1aSabhinav# 18*6cddff1aSabhinav# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19*6cddff1aSabhinav# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20*6cddff1aSabhinav# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21*6cddff1aSabhinav# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22*6cddff1aSabhinav# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*6cddff1aSabhinav# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*6cddff1aSabhinav# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*6cddff1aSabhinav# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*6cddff1aSabhinav# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*6cddff1aSabhinav# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*6cddff1aSabhinav# POSSIBILITY OF SUCH DAMAGE. 29*6cddff1aSabhinav# 30*6cddff1aSabhinav 31*6cddff1aSabhinavatf_test_case basic 32*6cddff1aSabhinavbasic_head() 33*6cddff1aSabhinav{ 34*6cddff1aSabhinav atf_set "descr" "Checks the basic functionality" 35*6cddff1aSabhinav} 36*6cddff1aSabhinavbasic_body() 37*6cddff1aSabhinav{ 38*6cddff1aSabhinav atf_check -o file:$(atf_get_srcdir)/d_basic.out uniq \ 39*6cddff1aSabhinav $(atf_get_srcdir)/d_basic.in 40*6cddff1aSabhinav} 41*6cddff1aSabhinav 42*6cddff1aSabhinavatf_test_case test_counts 43*6cddff1aSabhinavtest_counts_head() 44*6cddff1aSabhinav{ 45*6cddff1aSabhinav atf_set "descr" "Tests the -c option, comparing each line of the input" \ 46*6cddff1aSabhinav "file data starting from the second field" 47*6cddff1aSabhinav} 48*6cddff1aSabhinavtest_counts_body() 49*6cddff1aSabhinav{ 50*6cddff1aSabhinav atf_check -o file:$(atf_get_srcdir)/d_counts.out uniq -c -f 1 \ 51*6cddff1aSabhinav $(atf_get_srcdir)/d_input.in 52*6cddff1aSabhinav} 53*6cddff1aSabhinav 54*6cddff1aSabhinavatf_test_case show_duplicates 55*6cddff1aSabhinavshow_duplicates_head() 56*6cddff1aSabhinav{ 57*6cddff1aSabhinav atf_set "descr" "Checks the -d option, comparing each line of the input" \ 58*6cddff1aSabhinav "file data starting from the second field" 59*6cddff1aSabhinav} 60*6cddff1aSabhinavshow_duplicates_body() 61*6cddff1aSabhinav{ 62*6cddff1aSabhinav atf_check -o file:$(atf_get_srcdir)/d_show_duplicates.out uniq -d -f 1 \ 63*6cddff1aSabhinav $(atf_get_srcdir)/d_input.in 64*6cddff1aSabhinav} 65*6cddff1aSabhinav 66*6cddff1aSabhinavatf_test_case show_uniques 67*6cddff1aSabhinavshow_uniques_head() 68*6cddff1aSabhinav{ 69*6cddff1aSabhinav atf_set "descr" "Checks the -u option, comparing each line of the input" \ 70*6cddff1aSabhinav "file data starting from the second field" 71*6cddff1aSabhinav} 72*6cddff1aSabhinavshow_uniques_body() 73*6cddff1aSabhinav{ 74*6cddff1aSabhinav atf_check -o file:$(atf_get_srcdir)/d_show_uniques.out uniq -u -f 1 \ 75*6cddff1aSabhinav $(atf_get_srcdir)/d_input.in 76*6cddff1aSabhinav} 77*6cddff1aSabhinav 78*6cddff1aSabhinavatf_test_case show_duplicates_from_third_character 79*6cddff1aSabhinavshow_duplicates_from_third_character_head() 80*6cddff1aSabhinav{ 81*6cddff1aSabhinav atf_set "descr" "Checks the -d option, comparing each line of the input" \ 82*6cddff1aSabhinav "file data starting from the third character (-s option)" 83*6cddff1aSabhinav} 84*6cddff1aSabhinavshow_duplicates_from_third_character_body() 85*6cddff1aSabhinav{ 86*6cddff1aSabhinav atf_check -o empty uniq -d -s 2 $(atf_get_srcdir)/d_input.in 87*6cddff1aSabhinav 88*6cddff1aSabhinav} 89*6cddff1aSabhinav 90*6cddff1aSabhinavatf_init_test_cases() 91*6cddff1aSabhinav{ 92*6cddff1aSabhinav atf_add_test_case basic 93*6cddff1aSabhinav atf_add_test_case test_counts 94*6cddff1aSabhinav atf_add_test_case show_duplicates 95*6cddff1aSabhinav atf_add_test_case show_uniques 96*6cddff1aSabhinav atf_add_test_case show_duplicates_from_third_character 97*6cddff1aSabhinav} 98