1#!/usr/bin/env atf-sh 2# 3# Copyright (c) 2016,2017,2019 Daichi GOTO 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modifigation, are permitted provided that the following conditions are 8# met: 9# 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 2. Redistributions in binary form must reproduce the above copyright 13# notice, this list of conditions and the following disclaimer in the 14# documentation and/or other materials provided with the distribution. 15# 16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27# 28 29atf_test_case empty 30empty_head() { 31 atf_set "descr" "Verify an empty file" 32} 33 34empty_body() { 35 atf_check -s ignore \ 36 -o file:$(atf_get_srcdir)/empty_1.out \ 37 -x "gyo_delete 1=k $(atf_get_srcdir)/empty.in" 38 atf_check -s ignore \ 39 -o file:$(atf_get_srcdir)/empty_1.out \ 40 -x "gyo_delete 1=k < $(atf_get_srcdir)/empty.in" 41 atf_check -s ignore \ 42 -o file:$(atf_get_srcdir)/empty_1.out \ 43 -x "cat $(atf_get_srcdir)/empty.in |" \ 44 "gyo_delete 1=k" 45 atf_check -s ignore \ 46 -o file:$(atf_get_srcdir)/empty_1.out \ 47 -x "cat $(atf_get_srcdir)/empty.in |" \ 48 "gyo_delete 1=k -" 49 atf_check -s ignore \ 50 -o file:$(atf_get_srcdir)/empty_1.out \ 51 -x "gyo_delete 1/10=k $(atf_get_srcdir)/empty.in" 52 atf_check -s ignore \ 53 -o file:$(atf_get_srcdir)/empty_1.out \ 54 -x "gyo_delete 10/1=k $(atf_get_srcdir)/empty.in" 55 atf_check -s ignore \ 56 -o file:$(atf_get_srcdir)/empty_1.out \ 57 -x "gyo_delete 1=k" \ 58 "$(atf_get_srcdir)/empty.in" \ 59 "$(atf_get_srcdir)/empty.in" \ 60 "$(atf_get_srcdir)/empty.in" 61 atf_check -s ignore \ 62 -o file:$(atf_get_srcdir)/empty_1.out \ 63 -x "gyo_delete 5=k 1=k 3=k " \ 64 "$(atf_get_srcdir)/empty.in" \ 65 "$(atf_get_srcdir)/empty.in" 66 atf_check -s ignore \ 67 -o file:$(atf_get_srcdir)/empty_2.out \ 68 -x "gyo_delete 5=k 1=k 3=k " \ 69 "$(atf_get_srcdir)/empty.in" \ 70 "$(atf_get_srcdir)/empty.in" \ 71 "$(atf_get_srcdir)/data_without_eor.in" \ 72 "$(atf_get_srcdir)/empty.in" 73} 74 75atf_test_case opt_s_empty 76opt_s_empty_head() { 77 atf_set "descr" "Verify an empty file (with -s)" 78} 79 80opt_s_empty_body() { 81 atf_check -s ignore \ 82 -o file:$(atf_get_srcdir)/empty_1.out \ 83 -x "gyo_delete -s 1=k $(atf_get_srcdir)/empty.in" 84 atf_check -s ignore \ 85 -o file:$(atf_get_srcdir)/empty_1.out \ 86 -x "gyo_delete -s 1=k < $(atf_get_srcdir)/empty.in" 87 atf_check -s ignore \ 88 -o file:$(atf_get_srcdir)/empty_1.out \ 89 -x "cat $(atf_get_srcdir)/empty.in |" \ 90 "gyo_delete -s 1=k" 91 atf_check -s ignore \ 92 -o file:$(atf_get_srcdir)/empty_1.out \ 93 -x "cat $(atf_get_srcdir)/empty.in |" \ 94 "gyo_delete -s 1=k -" 95 atf_check -s ignore \ 96 -o file:$(atf_get_srcdir)/empty_1.out \ 97 -x "gyo_delete -s 1=k" \ 98 "$(atf_get_srcdir)/empty.in" \ 99 "$(atf_get_srcdir)/empty.in" \ 100 "$(atf_get_srcdir)/empty.in" 101} 102 103atf_test_case a_with_eor 104a_with_eor_head() { 105 atf_set "descr" "Verify a normal file including a LF before EoF" 106} 107 108a_with_eor_body() { 109 atf_check -s ignore \ 110 -o file:$(atf_get_srcdir)/a_with_eor_1.out \ 111 -x "gyo_delete 1=k $(atf_get_srcdir)/a_with_eor.in" 112 atf_check -s ignore \ 113 -o file:$(atf_get_srcdir)/a_with_eor_1.out \ 114 -x "gyo_delete 1=k < $(atf_get_srcdir)/a_with_eor.in" 115 atf_check -s ignore \ 116 -o file:$(atf_get_srcdir)/a_with_eor_1.out \ 117 -x "cat $(atf_get_srcdir)/a_with_eor.in |" \ 118 "gyo_delete 1=k" 119 atf_check -s ignore \ 120 -o file:$(atf_get_srcdir)/a_with_eor_1.out \ 121 -x "cat $(atf_get_srcdir)/a_with_eor.in |" \ 122 "gyo_delete 1=k -" 123 atf_check -s ignore \ 124 -o file:$(atf_get_srcdir)/a_with_eor_1.out \ 125 -x "gyo_delete 1/10=k $(atf_get_srcdir)/a_with_eor.in" 126 atf_check -s ignore \ 127 -o file:$(atf_get_srcdir)/a_with_eor_1.out \ 128 -x "gyo_delete 10/1=k $(atf_get_srcdir)/a_with_eor.in" 129 atf_check -s ignore \ 130 -o file:$(atf_get_srcdir)/a_with_eor_2.out \ 131 -x "gyo_delete 1=k" \ 132 "$(atf_get_srcdir)/a_with_eor.in" \ 133 "$(atf_get_srcdir)/a_with_eor.in" \ 134 "$(atf_get_srcdir)/a_with_eor.in" 135 atf_check -s ignore \ 136 -o file:$(atf_get_srcdir)/a_with_eor_3.out \ 137 -x "gyo_delete 5=k 1=k 3=k" \ 138 "$(atf_get_srcdir)/a_with_eor.in" \ 139 "$(atf_get_srcdir)/a_with_eor.in" 140} 141 142atf_test_case opt_s_a_with_eor 143opt_s_a_with_eor_head() { 144 atf_set "descr" "Verify a normal file including a LF before EoF (with -s)" 145} 146 147opt_s_a_with_eor_body() { 148 atf_check -s ignore \ 149 -o file:$(atf_get_srcdir)/a_with_eor_1.out \ 150 -x "gyo_delete -s 1=k $(atf_get_srcdir)/a_with_eor.in" 151 atf_check -s ignore \ 152 -o file:$(atf_get_srcdir)/a_with_eor_1.out \ 153 -x "gyo_delete -s 1=k < $(atf_get_srcdir)/a_with_eor.in" 154 atf_check -s ignore \ 155 -o file:$(atf_get_srcdir)/a_with_eor_1.out \ 156 -x "cat $(atf_get_srcdir)/a_with_eor.in |" \ 157 "gyo_delete -s 1=k" 158 atf_check -s ignore \ 159 -o file:$(atf_get_srcdir)/a_with_eor_1.out \ 160 -x "cat $(atf_get_srcdir)/a_with_eor.in |" \ 161 "gyo_delete -s 1=k -" 162 atf_check -s ignore \ 163 -o file:$(atf_get_srcdir)/a_with_eor_2.out \ 164 -x "gyo_delete 1=k" \ 165 "$(atf_get_srcdir)/a_with_eor.in" \ 166 "$(atf_get_srcdir)/a_with_eor.in" \ 167 "$(atf_get_srcdir)/a_with_eor.in" 168} 169 170atf_test_case a_without_eor 171a_without_eor_head() { 172 atf_set "descr" "Verify a normal file excluding a LF before EoF" 173} 174 175a_without_eor_body() { 176 atf_check -s ignore \ 177 -o file:$(atf_get_srcdir)/a_without_eor_1.out \ 178 -x "gyo_delete 1=k $(atf_get_srcdir)/a_without_eor.in" 179 atf_check -s ignore \ 180 -o file:$(atf_get_srcdir)/a_without_eor_1.out \ 181 -x "gyo_delete 1=k < $(atf_get_srcdir)/a_without_eor.in" 182 atf_check -s ignore \ 183 -o file:$(atf_get_srcdir)/a_without_eor_1.out \ 184 -x "cat $(atf_get_srcdir)/a_without_eor.in |" \ 185 "gyo_delete 1=k" 186 atf_check -s ignore \ 187 -o file:$(atf_get_srcdir)/a_without_eor_1.out \ 188 -x "cat $(atf_get_srcdir)/a_without_eor.in |" \ 189 "gyo_delete 1=k -" 190 atf_check -s ignore \ 191 -o file:$(atf_get_srcdir)/a_without_eor_1.out \ 192 -x "gyo_delete 1/10=k $(atf_get_srcdir)/a_without_eor.in" 193 atf_check -s ignore \ 194 -o file:$(atf_get_srcdir)/a_without_eor_1.out \ 195 -x "gyo_delete 10/1=k $(atf_get_srcdir)/a_without_eor.in" 196 atf_check -s ignore \ 197 -o file:$(atf_get_srcdir)/a_without_eor_2.out \ 198 -x "gyo_delete 1=k" \ 199 "$(atf_get_srcdir)/a_without_eor.in" \ 200 "$(atf_get_srcdir)/a_without_eor.in" \ 201 "$(atf_get_srcdir)/a_without_eor.in" 202 atf_check -s ignore \ 203 -o file:$(atf_get_srcdir)/a_without_eor_3.out \ 204 -x "gyo_delete 5=k 1=k 3=k" \ 205 "$(atf_get_srcdir)/a_without_eor.in" \ 206 "$(atf_get_srcdir)/a_without_eor.in" 207} 208 209atf_test_case opt_s_a_without_eor 210opt_s_a_without_eor_head() { 211 atf_set "descr" "Verify a normal file excluding a LF before EoF (with -s)" 212} 213 214opt_s_a_without_eor_body() { 215 atf_check -s ignore \ 216 -o file:$(atf_get_srcdir)/opt_s_a_without_eor_1.out \ 217 -x "gyo_delete -s 1=k $(atf_get_srcdir)/a_without_eor.in" 218 atf_check -s ignore \ 219 -o file:$(atf_get_srcdir)/opt_s_a_without_eor_1.out \ 220 -x "gyo_delete -s 1=k < $(atf_get_srcdir)/a_without_eor.in" 221 atf_check -s ignore \ 222 -o file:$(atf_get_srcdir)/opt_s_a_without_eor_1.out \ 223 -x "cat $(atf_get_srcdir)/a_without_eor.in |" \ 224 "gyo_delete -s 1=k" 225 atf_check -s ignore \ 226 -o file:$(atf_get_srcdir)/opt_s_a_without_eor_1.out \ 227 -x "cat $(atf_get_srcdir)/a_without_eor.in |" \ 228 "gyo_delete -s 1=k -" 229 atf_check -s ignore \ 230 -o file:$(atf_get_srcdir)/opt_s_a_without_eor_2.out \ 231 -x "gyo_delete -s 1=k" \ 232 "$(atf_get_srcdir)/a_without_eor.in" \ 233 "$(atf_get_srcdir)/a_without_eor.in" \ 234 "$(atf_get_srcdir)/a_without_eor.in" 235} 236 237atf_test_case fl_with_eor 238fl_with_eor_head() { 239 atf_set "descr" "Verify a one column file including a LF before EoF" 240} 241 242fl_with_eor_body() { 243 atf_check -s ignore \ 244 -o file:$(atf_get_srcdir)/fl_with_eor_1.out \ 245 -x "gyo_delete 1= $(atf_get_srcdir)/fl_with_eor.in" 246 atf_check -s ignore \ 247 -o file:$(atf_get_srcdir)/fl_with_eor_2.out \ 248 -x "gyo_delete 1=b $(atf_get_srcdir)/fl_with_eor.in" 249 atf_check -s ignore \ 250 -o file:$(atf_get_srcdir)/fl_with_eor_3.out \ 251 -x "gyo_delete 1=k $(atf_get_srcdir)/fl_with_eor.in" 252 atf_check -s ignore \ 253 -o file:$(atf_get_srcdir)/fl_with_eor_4.out \ 254 -x "gyo_delete 2= $(atf_get_srcdir)/fl_with_eor.in" 255} 256 257atf_test_case opt_s_fl_with_eor 258opt_s_fl_with_eor_head() { 259 atf_set "descr" "Verify a one column file including a LF before EoF (with -s)" 260} 261 262opt_s_fl_with_eor_body() { 263 atf_check -s ignore \ 264 -o file:$(atf_get_srcdir)/fl_with_eor_1.out \ 265 -x "gyo_delete -s 1= $(atf_get_srcdir)/fl_with_eor.in" 266 atf_check -s ignore \ 267 -o file:$(atf_get_srcdir)/opt_s_fl_with_eor_2.out \ 268 -x "gyo_delete -s 1=b $(atf_get_srcdir)/fl_with_eor.in" 269 atf_check -s ignore \ 270 -o file:$(atf_get_srcdir)/opt_s_fl_with_eor_3.out \ 271 -x "gyo_delete -s 1=k $(atf_get_srcdir)/fl_with_eor.in" 272 atf_check -s ignore \ 273 -o file:$(atf_get_srcdir)/opt_s_fl_with_eor_4.out \ 274 -x "gyo_delete -s 2= $(atf_get_srcdir)/fl_with_eor.in" 275} 276 277atf_test_case data_with_eor 278data_with_eor_head() { 279 atf_set "descr" "Verify a normal file including a LF before EoF" 280} 281 282data_with_eor_body() { 283 atf_check -s ignore \ 284 -o file:$(atf_get_srcdir)/data_with_eor_1.out \ 285 -x "gyo_delete 1=k $(atf_get_srcdir)/data_with_eor.in" 286 atf_check -s ignore \ 287 -o file:$(atf_get_srcdir)/data_with_eor_1.out \ 288 -x "gyo_delete 1=k < $(atf_get_srcdir)/data_with_eor.in" 289 atf_check -s ignore \ 290 -o file:$(atf_get_srcdir)/data_with_eor_1.out \ 291 -x "cat $(atf_get_srcdir)/data_with_eor.in |" \ 292 "gyo_delete 1=k" 293 atf_check -s ignore \ 294 -o file:$(atf_get_srcdir)/data_with_eor_1.out \ 295 -x "cat $(atf_get_srcdir)/data_with_eor.in |" \ 296 "gyo_delete 1=k -" 297 atf_check -s ignore \ 298 -o file:$(atf_get_srcdir)/data_with_eor_2.out \ 299 -x "gyo_delete 1=k" \ 300 "$(atf_get_srcdir)/data_with_eor.in" \ 301 "$(atf_get_srcdir)/data_with_eor.in" \ 302 "$(atf_get_srcdir)/data_with_eor.in" 303 atf_check -s ignore \ 304 -o file:$(atf_get_srcdir)/data_with_eor_3.out \ 305 -x "gyo_delete 2=bb 4=dd" \ 306 "$(atf_get_srcdir)/data_with_eor.in" 307 atf_check -s ignore \ 308 -o file:$(atf_get_srcdir)/data_with_eor_4.out \ 309 -x "gyo_delete 2=bb 9=dd" \ 310 "$(atf_get_srcdir)/data_with_eor.in" 311 atf_check -s ignore \ 312 -o file:$(atf_get_srcdir)/data_with_eor_5.out \ 313 -x "gyo_delete 2=bb" \ 314 "$(atf_get_srcdir)/data_with_eor.in" \ 315 "$(atf_get_srcdir)/a_with_eor.in" \ 316 "$(atf_get_srcdir)/empty.in" \ 317 "$(atf_get_srcdir)/a_with_eor.in" 318} 319 320atf_test_case opt_s_data_with_eor 321opt_s_data_with_eor_head() { 322 atf_set "descr" "Verify a normal file including a LF before EoF (with -d)" 323} 324 325opt_s_data_with_eor_body() { 326 atf_check -s ignore \ 327 -o file:$(atf_get_srcdir)/opt_s_data_with_eor_1.out \ 328 -x "gyo_delete -s 1=k $(atf_get_srcdir)/data_with_eor.in" 329 atf_check -s ignore \ 330 -o file:$(atf_get_srcdir)/opt_s_data_with_eor_1.out \ 331 -x "gyo_delete -s 1=k < $(atf_get_srcdir)/data_with_eor.in" 332 atf_check -s ignore \ 333 -o file:$(atf_get_srcdir)/opt_s_data_with_eor_1.out \ 334 -x "cat $(atf_get_srcdir)/data_with_eor.in |" \ 335 "gyo_delete -s 1=k" 336 atf_check -s ignore \ 337 -o file:$(atf_get_srcdir)/opt_s_data_with_eor_1.out \ 338 -x "cat $(atf_get_srcdir)/data_with_eor.in |" \ 339 "gyo_delete -s 1=k -" 340 atf_check -s ignore \ 341 -o file:$(atf_get_srcdir)/opt_s_data_with_eor_2.out \ 342 -x "gyo_delete -s 1=k" \ 343 "$(atf_get_srcdir)/data_with_eor.in" \ 344 "$(atf_get_srcdir)/data_with_eor.in" \ 345 "$(atf_get_srcdir)/data_with_eor.in" 346 atf_check -s ignore \ 347 -o file:$(atf_get_srcdir)/opt_s_data_with_eor_5.out \ 348 -x "gyo_delete -s 2=bb" \ 349 "$(atf_get_srcdir)/data_with_eor.in" \ 350 "$(atf_get_srcdir)/a_with_eor.in" \ 351 "$(atf_get_srcdir)/empty.in" \ 352 "$(atf_get_srcdir)/a_with_eor.in" 353} 354 355atf_test_case data_without_eor 356data_without_eor_head() { 357 atf_set "descr" "Verify a normal file including a LF before EoF" 358} 359 360data_without_eor_body() { 361 atf_check -s ignore \ 362 -o file:$(atf_get_srcdir)/data_without_eor_1.out \ 363 -x "gyo_delete 1=k $(atf_get_srcdir)/data_without_eor.in" 364 atf_check -s ignore \ 365 -o file:$(atf_get_srcdir)/data_without_eor_1.out \ 366 -x "gyo_delete 1=k < $(atf_get_srcdir)/data_without_eor.in" 367 atf_check -s ignore \ 368 -o file:$(atf_get_srcdir)/data_without_eor_1.out \ 369 -x "cat $(atf_get_srcdir)/data_without_eor.in |" \ 370 "gyo_delete 1=k" 371 atf_check -s ignore \ 372 -o file:$(atf_get_srcdir)/data_without_eor_1.out \ 373 -x "cat $(atf_get_srcdir)/data_without_eor.in |" \ 374 "gyo_delete 1=k -" 375 atf_check -s ignore \ 376 -o file:$(atf_get_srcdir)/data_without_eor_2.out \ 377 -x "gyo_delete 1=k" \ 378 "$(atf_get_srcdir)/data_without_eor.in" \ 379 "$(atf_get_srcdir)/data_without_eor.in" \ 380 "$(atf_get_srcdir)/data_without_eor.in" 381 atf_check -s ignore \ 382 -o file:$(atf_get_srcdir)/data_without_eor_3.out \ 383 -x "gyo_delete 2=bb 4=dd" \ 384 "$(atf_get_srcdir)/data_without_eor.in" 385 atf_check -s ignore \ 386 -o file:$(atf_get_srcdir)/data_without_eor_4.out \ 387 -x "gyo_delete 2=bb 9=dd" \ 388 "$(atf_get_srcdir)/data_without_eor.in" 389 atf_check -s ignore \ 390 -o file:$(atf_get_srcdir)/data_without_eor_5.out \ 391 -x "gyo_delete 2=bb" \ 392 "$(atf_get_srcdir)/data_without_eor.in" \ 393 "$(atf_get_srcdir)/a_without_eor.in" \ 394 "$(atf_get_srcdir)/empty.in" \ 395 "$(atf_get_srcdir)/a_without_eor.in" 396} 397 398atf_test_case opt_s_data_without_eor 399opt_s_data_without_eor_head() { 400 atf_set "descr" "Verify a normal file including a LF before EoF (with -s)" 401} 402 403opt_s_data_without_eor_body() { 404 atf_check -s ignore \ 405 -o file:$(atf_get_srcdir)/opt_s_data_without_eor_1.out \ 406 -x "gyo_delete -s 1=k $(atf_get_srcdir)/data_without_eor.in" 407 atf_check -s ignore \ 408 -o file:$(atf_get_srcdir)/opt_s_data_without_eor_1.out \ 409 -x "gyo_delete -s 1=k < $(atf_get_srcdir)/data_without_eor.in" 410 atf_check -s ignore \ 411 -o file:$(atf_get_srcdir)/opt_s_data_without_eor_1.out \ 412 -x "cat $(atf_get_srcdir)/data_without_eor.in |" \ 413 "gyo_delete -s 1=k" 414 atf_check -s ignore \ 415 -o file:$(atf_get_srcdir)/opt_s_data_without_eor_1.out \ 416 -x "cat $(atf_get_srcdir)/data_without_eor.in |" \ 417 "gyo_delete -s 1=k -" 418 atf_check -s ignore \ 419 -o file:$(atf_get_srcdir)/opt_s_data_without_eor_2.out \ 420 -x "gyo_delete -s 1=k" \ 421 "$(atf_get_srcdir)/data_without_eor.in" \ 422 "$(atf_get_srcdir)/data_without_eor.in" \ 423 "$(atf_get_srcdir)/data_without_eor.in" 424 atf_check -s ignore \ 425 -o file:$(atf_get_srcdir)/opt_s_data_without_eor_5.out \ 426 -x "gyo_delete -s 2=bb" \ 427 "$(atf_get_srcdir)/data_without_eor.in" \ 428 "$(atf_get_srcdir)/a_without_eor.in" \ 429 "$(atf_get_srcdir)/empty.in" \ 430 "$(atf_get_srcdir)/a_without_eor.in" 431} 432 433atf_test_case and_condition 434and_condition_head() { 435 atf_set "descr" "Verify AND condition" 436} 437 438and_condition_body() { 439 atf_check -s ignore \ 440 -o file:$(atf_get_srcdir)/and_1.out \ 441 -x "gyo_delete 1=aa" \ 442 "$(atf_get_srcdir)/data_with_eor.in" 443 atf_check -s ignore \ 444 -o file:$(atf_get_srcdir)/and_2.out \ 445 -x "gyo_delete 1=aa 2=bb" \ 446 "$(atf_get_srcdir)/data_with_eor.in" 447 atf_check -s ignore \ 448 -o file:$(atf_get_srcdir)/and_3.out \ 449 -x "gyo_delete 1=aa 2=bb 3=cc" \ 450 "$(atf_get_srcdir)/data_with_eor.in" 451 atf_check -s ignore \ 452 -o file:$(atf_get_srcdir)/and_4.out \ 453 -x "gyo_delete 1=aa 2=bb 3=cc 4=dd" \ 454 "$(atf_get_srcdir)/data_with_eor.in" 455 atf_check -s ignore \ 456 -o file:$(atf_get_srcdir)/and_5.out \ 457 -x "gyo_delete 1=aa 2=bb 3=cc 4=dd 5=ee" \ 458 "$(atf_get_srcdir)/data_with_eor.in" 459 atf_check -s ignore \ 460 -o file:$(atf_get_srcdir)/and_6.out \ 461 -x "gyo_delete 1=aa 2=bb 3=cc 4=dd 5=ee 6=ff" \ 462 "$(atf_get_srcdir)/data_with_eor.in" 463} 464 465atf_test_case or_condition 466or_condition_head() { 467 atf_set "descr" "Verify OR condition" 468} 469 470or_condition_body() { 471 atf_check -s ignore \ 472 -o file:$(atf_get_srcdir)/or_1.out \ 473 -x "gyo_delete -o 2=" \ 474 "$(atf_get_srcdir)/data_with_eor.in" 475 atf_check -s ignore \ 476 -o file:$(atf_get_srcdir)/or_2.out \ 477 -x "gyo_delete -o 2= 3=" \ 478 "$(atf_get_srcdir)/data_with_eor.in" 479 atf_check -s ignore \ 480 -o file:$(atf_get_srcdir)/or_3.out \ 481 -x "gyo_delete -o 2= 3= 4=" \ 482 "$(atf_get_srcdir)/data_with_eor.in" 483 atf_check -s ignore \ 484 -o file:$(atf_get_srcdir)/or_4.out \ 485 -x "gyo_delete -o 2= 3= 4= 5=" \ 486 "$(atf_get_srcdir)/data_with_eor.in" 487 atf_check -s ignore \ 488 -o file:$(atf_get_srcdir)/or_5.out \ 489 -x "gyo_delete -o 2= 3= 4= 5= 6=" \ 490 "$(atf_get_srcdir)/data_with_eor.in" 491 atf_check -s ignore \ 492 -o file:$(atf_get_srcdir)/or_6.out \ 493 -x "gyo_delete -o 2= 2=2" \ 494 "$(atf_get_srcdir)/empty.in" 495} 496 497atf_test_case greaterthan 498greaterthen_head() { 499 atf_set "descr" "Verify GREATERTHAN condition" 500} 501 502greaterthan_body() { 503 atf_check -s ignore \ 504 -o file:$(atf_get_srcdir)/date_with_eor_1.out \ 505 -x "gyo_delete 3'>'20130202" \ 506 "$(atf_get_srcdir)/date_with_eor.in" 507 atf_check -s ignore \ 508 -o file:$(atf_get_srcdir)/date_with_eor_2.out \ 509 -x "gyo_delete 3'>'20130202 4'>'20150404" \ 510 "$(atf_get_srcdir)/date_with_eor.in" 511} 512 513atf_test_case opt_s_greaterthan 514opt_s_greaterthen_head() { 515 atf_set "descr" "Verify GREATERTHAN condition (with -s)" 516} 517 518opt_s_greaterthan_body() { 519 atf_check -s ignore \ 520 -o file:$(atf_get_srcdir)/date_with_eor_1.out \ 521 -x "gyo_delete -s 3'>'20130202" \ 522 "$(atf_get_srcdir)/date_with_eor.in" 523} 524 525atf_test_case opt_s_greaterthan_or_equal_to 526opt_s_greaterthen_or_equal_to_head() { 527 atf_set "descr" "Verify GREATERTHAN condition (with -s)" 528} 529 530opt_s_greaterthan_or_equal_to_body() { 531 atf_check -s ignore \ 532 -o file:$(atf_get_srcdir)/opt_s_date_with_eor_1.out \ 533 -x "gyo_delete -s 3'>='20150202" \ 534 "$(atf_get_srcdir)/date_with_eor.in" 535 atf_check -s ignore \ 536 -o file:$(atf_get_srcdir)/opt_s_date_with_eor_1.out \ 537 -x "gyo_delete -s 3'=>'20150202" \ 538 "$(atf_get_srcdir)/date_with_eor.in" 539} 540 541atf_test_case lesserthan 542lesserthan_head() { 543 atf_set "descr" "Verify LESSERTHAN condition" 544} 545 546lesserthan_body() { 547 atf_check -s ignore \ 548 -o file:$(atf_get_srcdir)/date_with_eor_3.out \ 549 -x "gyo_delete 3'<'20130203" \ 550 "$(atf_get_srcdir)/date_with_eor.in" 551 atf_check -s ignore \ 552 -o file:$(atf_get_srcdir)/date_with_eor_4.out \ 553 -x "gyo_delete 3'<'20170101 5'<'20160404" \ 554 "$(atf_get_srcdir)/date_with_eor.in" 555} 556 557atf_test_case opt_s_lesserthan 558opt_s_lesserthan_head() { 559 atf_set "descr" "Verify LESSERTHAN condition (with -s)" 560} 561 562opt_s_lesserthan_body() { 563 atf_check -s ignore \ 564 -o file:$(atf_get_srcdir)/date_with_eor_3.out \ 565 -x "gyo_delete 3'<'20130203" \ 566 "$(atf_get_srcdir)/date_with_eor.in" 567} 568 569atf_test_case opt_s_lesserthan_or_equal_to 570opt_s_lesserthan_or_equal_to_head() { 571 atf_set "descr" "Verify LESSERTHAN condition (with -s)" 572} 573 574opt_s_lesserthan_or_equal_to_body() { 575 atf_check -s ignore \ 576 -o file:$(atf_get_srcdir)/opt_s_date_with_eor_3.out \ 577 -x "gyo_delete -s 3'<='20140202" \ 578 "$(atf_get_srcdir)/date_with_eor.in" 579 atf_check -s ignore \ 580 -o file:$(atf_get_srcdir)/opt_s_date_with_eor_3.out \ 581 -x "gyo_delete -s 3'=<'20140202" \ 582 "$(atf_get_srcdir)/date_with_eor.in" 583} 584 585atf_test_case multiple_and_condition 586multiple_and_condition_head() { 587 atf_set "descr" "Verity MULTIPLE-AND condition" 588} 589 590multiple_and_condition_body() { 591 atf_check -s ignore \ 592 -o file:$(atf_get_srcdir)/multiple_and_condition_1.out \ 593 -x "gyo_delete 2= 2=bb" \ 594 "$(atf_get_srcdir)/data_with_eor.in" 595 atf_check -s ignore \ 596 -o file:$(atf_get_srcdir)/multiple_and_condition_2.out \ 597 -x "gyo_delete 3'>'20130202 3'<'20160202" \ 598 "$(atf_get_srcdir)/date_with_eor.in" 599 atf_check -s ignore \ 600 -o file:$(atf_get_srcdir)/multiple_and_condition_3.out \ 601 -x "gyo_delete 3'<'20130202 3'>'20160202" \ 602 "$(atf_get_srcdir)/date_with_eor.in" 603} 604 605atf_test_case multiple_or_condition 606multiple_or_condition_head() { 607 atf_set "descr" "Verity MULTIPLE-OR condition" 608} 609 610multiple_or_condition_body() { 611 atf_check -s ignore \ 612 -o file:$(atf_get_srcdir)/multiple_or_condition_1.out \ 613 -x "gyo_delete -o 2= 2=bb" \ 614 "$(atf_get_srcdir)/data_with_eor.in" 615 atf_check -s ignore \ 616 -o file:$(atf_get_srcdir)/multiple_or_condition_2.out \ 617 -x "gyo_delete -o 3'>'20130202 3'<'20160202" \ 618 "$(atf_get_srcdir)/date_with_eor.in" 619 atf_check -s ignore \ 620 -o file:$(atf_get_srcdir)/multiple_or_condition_3.out \ 621 -x "gyo_delete -o 3=20130202 3=20160202" \ 622 "$(atf_get_srcdir)/date_with_eor.in" 623} 624 625atf_test_case join 626join_head() { 627 atf_set "descr" "Verity JOIN process" 628} 629 630join_body() { 631 atf_check -s ignore \ 632 -o file:$(atf_get_srcdir)/join_1.out \ 633 -x "gyo_delete" \ 634 "1:$(atf_get_srcdir)/key.ssv:2" \ 635 "$(atf_get_srcdir)/date_with_eor.in" 636 atf_check -s ignore \ 637 -o file:$(atf_get_srcdir)/join_2.out \ 638 -x "gyo_delete" \ 639 "1:$(atf_get_srcdir)/key.ssv:3" \ 640 "$(atf_get_srcdir)/date_with_eor.in" 641 atf_check -s ignore \ 642 -o file:$(atf_get_srcdir)/join_3.out \ 643 -x "gyo_delete" \ 644 "4:$(atf_get_srcdir)/key.ssv:3" \ 645 "$(atf_get_srcdir)/date_with_eor.in" 646 atf_check -s ignore \ 647 -o file:$(atf_get_srcdir)/join_4.out \ 648 -x "gyo_delete -o " \ 649 "1:$(atf_get_srcdir)/key.ssv:2" \ 650 "4=20160303" \ 651 "$(atf_get_srcdir)/date_with_eor.in" 652} 653 654atf_test_case option_n 655option_n_head() { 656 atf_set "descr" "Verity -n process" 657} 658 659option_n_body() { 660 atf_check -s ignore \ 661 -o file:$(atf_get_srcdir)/option_n_1.out \ 662 -x "echo 1 2 3 4 5 |" \ 663 "gyo_delete -n 1=1 && echo outputed" 664 atf_check -s ignore \ 665 -o file:$(atf_get_srcdir)/option_n_2.out \ 666 -x "echo 1 2 3 4 5 |" \ 667 "gyo_delete -n 1=2 && echo outputed" 668 atf_check -s ignore \ 669 -o file:$(atf_get_srcdir)/option_n_2.out \ 670 -x "echo 1 2 3 4 5 |" \ 671 "gyo_delete -n 1=1 || echo outputed" 672 atf_check -s ignore \ 673 -o file:$(atf_get_srcdir)/option_n_1.out \ 674 -x "echo 1 2 3 4 5 |" \ 675 "gyo_delete -n 1=2 || echo outputed" 676} 677 678atf_test_case numeric_compare 679numeric_compare_head() { 680 atf_set "descr" "Verity -N process" 681} 682 683numeric_compare_body() { 684 atf_check -s ignore \ 685 -o file:$(atf_get_srcdir)/numeric_compare_1.out \ 686 -x "echo 10 20 30 40 50 |" \ 687 "gyo_delete 5'>'6" 688 atf_check -s ignore \ 689 -o file:$(atf_get_srcdir)/numeric_compare_2.out \ 690 -x "echo 10 20 30 40 50 |" \ 691 "gyo_delete -N 5'>'6" 692 atf_check -s ignore \ 693 -o file:$(atf_get_srcdir)/numeric_compare_3.out \ 694 -x "cat $(atf_get_srcdir)/nums_with_eor.in |" \ 695 "gyo_delete -N 2'>'1" 696 atf_check -s ignore \ 697 -o file:$(atf_get_srcdir)/numeric_compare_4.out \ 698 -x "cat $(atf_get_srcdir)/nums_with_eor.in |" \ 699 "gyo_delete -N 4'>'1" 700} 701 702atf_test_case remove_first_line 703remove_first_line_head() { 704 atf_set "descr" "Verify a -1 option" 705} 706 707remove_first_line_body() { 708 atf_check -s ignore \ 709 -o file:$(atf_get_srcdir)/remove_first_line_1.out \ 710 -x "gyo_delete -1 -N 2'<'0" \ 711 "$(atf_get_srcdir)/price.tag" 712} 713 714atf_test_case atmark 715atmark_head() { 716 atf_set "descr" "Verify an atmark process" 717} 718 719atmark_body() { 720 atf_check -s ignore \ 721 -o file:$(atf_get_srcdir)/atmark_1.out \ 722 -x "gyo_delete -1 -N 1'>'0" \ 723 "$(atf_get_srcdir)/price2.tag" 724 atf_check -s ignore \ 725 -o file:$(atf_get_srcdir)/atmark_2.out \ 726 -x "gyo_delete -1 -N 2'>'0" \ 727 "$(atf_get_srcdir)/price2.tag" 728 atf_check -s ignore \ 729 -o file:$(atf_get_srcdir)/atmark_3.out \ 730 -x "gyo_delete -1 1." \ 731 "$(atf_get_srcdir)/price2.tag" 732 atf_check -s ignore \ 733 -o file:$(atf_get_srcdir)/atmark_4.out \ 734 -x "gyo_delete -1 2." \ 735 "$(atf_get_srcdir)/price2.tag" 736} 737 738atf_test_case opt_s_atmark 739opt_s_atmark_head() { 740 atf_set "descr" "Verify an atmark process (with -s)" 741} 742 743opt_s_atmark_body() { 744 atf_check -s ignore \ 745 -o file:$(atf_get_srcdir)/opt_s_atmark_3.out \ 746 -x "gyo_delete -s 1." \ 747 "$(atf_get_srcdir)/price2.tag" 748 atf_check -s ignore \ 749 -o file:$(atf_get_srcdir)/opt_s_atmark_4.out \ 750 -x "gyo_delete -s 2." \ 751 "$(atf_get_srcdir)/price2.tag" 752} 753 754atf_test_case select 755select_head() { 756 atf_set "descr" "Verify a select process" 757} 758 759select_body() { 760 atf_check -s ignore \ 761 -o file:$(atf_get_srcdir)/select_1.out \ 762 -x "gyo_delete -1 -N 1'>'0 1 2 3/1" \ 763 "$(atf_get_srcdir)/price2.tag" 764 atf_check -s ignore \ 765 -o file:$(atf_get_srcdir)/select_2.out \ 766 -x "gyo_delete -1 -N 2'>'0 1 2 3/1" \ 767 "$(atf_get_srcdir)/price2.tag" 768 atf_check -s ignore \ 769 -o file:$(atf_get_srcdir)/select_3.out \ 770 -x "gyo_delete -1 1. 3 2/1" \ 771 "$(atf_get_srcdir)/price2.tag" 772 atf_check -s ignore \ 773 -o file:$(atf_get_srcdir)/select_4.out \ 774 -x "gyo_delete -1 2. 3 2/1" \ 775 "$(atf_get_srcdir)/price2.tag" 776} 777 778atf_test_case empty_output 779empty_output_head() { 780 atf_set "descr" "Verify an empty output process" 781} 782 783empty_output_body() { 784 atf_check -s ignore \ 785 -o file:$(atf_get_srcdir)/empty_output_1.out \ 786 -x "echo |" \ 787 "gyo_delete -@ 000000 1.NOT 1/5" 788 atf_check -s ignore \ 789 -o file:$(atf_get_srcdir)/empty_output_2.out \ 790 -x "echo |" \ 791 "gyo_delete -@ ' @__ ' 1.NOT 1/5" 792 atf_check -s ignore \ 793 -o file:$(atf_get_srcdir)/empty_output_3.out \ 794 -x "echo |" \ 795 "gyo_delete 1. 1/5" 796 atf_check -s ignore \ 797 -o file:$(atf_get_srcdir)/empty_output_4.out \ 798 -x "echo 1 2 3 4 5 |" \ 799 "gyo_delete -e 1.1" 800 atf_check -s ignore \ 801 -o file:$(atf_get_srcdir)/empty_output_5.out \ 802 -x "echo |" \ 803 "gyo_delete -e 1. 1/5" 804 atf_check -s ignore \ 805 -o file:$(atf_get_srcdir)/empty_output_6.out \ 806 -x "echo |" \ 807 "gyo_delete -e -@ 0 1. 1/5" 808} 809 810atf_test_case zero 811zero_head() { 812 atf_set "descr" "Verify a zero retu process" 813} 814 815zero_body() { 816 atf_check -s ignore \ 817 -o file:$(atf_get_srcdir)/zero_1.out \ 818 -x "echo 1 2 3 4 5 |" \ 819 "gyo_delete 1=0 0 0 1 0 0 6 6" 820} 821 822atf_test_case not_match 823not_match_head() { 824 atf_set "descr" "Verify a not-match condition process" 825} 826 827not_match_body() { 828 atf_check -s ignore \ 829 -o file:$(atf_get_srcdir)/not_match_1.out \ 830 -x "gyo_delete 2!bb $(atf_get_srcdir)/data_with_eor.in" 831 atf_check -s ignore \ 832 -o file:$(atf_get_srcdir)/not_match_2.out \ 833 -x "gyo_delete 2! $(atf_get_srcdir)/data_with_eor.in" 834 atf_check -s ignore \ 835 -o file:$(atf_get_srcdir)/not_match_3.out \ 836 -x "gyo_delete 2! 3! 4! $(atf_get_srcdir)/data_with_eor.in" 837} 838 839atf_test_case opt_s_not_match 840opt_s_not_match_head() { 841 atf_set "descr" "Verify a not-match condition process (with -s)" 842} 843 844opt_s_not_match_body() { 845 atf_check -s ignore \ 846 -o file:$(atf_get_srcdir)/opt_s_not_match_1.out \ 847 -x "gyo_delete -s 2!bb $(atf_get_srcdir)/data_with_eor.in" 848 atf_check -s ignore \ 849 -o file:$(atf_get_srcdir)/opt_s_not_match_2.out \ 850 -x "gyo_delete -s 2! $(atf_get_srcdir)/data_with_eor.in" 851} 852 853atf_test_case long 854long_head() { 855 atf_set "descr" "Verify a long data process" 856} 857 858long_body() { 859 atf_check -s ignore \ 860 -o file:$(atf_get_srcdir)/long_data_1.out \ 861 -x "gyo_delete 2!2 $(atf_get_srcdir)/long_data.in" 862 atf_check -s ignore \ 863 -o file:$(atf_get_srcdir)/long_data_1.out \ 864 -x "gyo_delete 200000!200000 $(atf_get_srcdir)/long_data.in" 865 atf_check -s ignore \ 866 -o file:$(atf_get_srcdir)/long_data_2.out \ 867 -x "gyo_delete 2!3 $(atf_get_srcdir)/long_data.in" 868} 869 870atf_test_case opt_s_long 871opt_s_long_head() { 872 atf_set "descr" "Verify a long data process (with -s)" 873} 874 875opt_s_long_body() { 876 atf_check -s ignore \ 877 -o file:$(atf_get_srcdir)/long_data_1.out \ 878 -x "gyo_delete 2!2 $(atf_get_srcdir)/long_data.in" 879 atf_check -s ignore \ 880 -o file:$(atf_get_srcdir)/long_data_1.out \ 881 -x "gyo_delete 200000!200000 $(atf_get_srcdir)/long_data.in" 882 atf_check -s ignore \ 883 -o file:$(atf_get_srcdir)/long_data_2.out \ 884 -x "gyo_delete 2!3 $(atf_get_srcdir)/long_data.in" 885} 886 887atf_init_test_cases() 888{ 889 atf_add_test_case empty 890 atf_add_test_case a_with_eor 891 atf_add_test_case a_without_eor 892 atf_add_test_case fl_with_eor 893 atf_add_test_case data_with_eor 894 atf_add_test_case data_without_eor 895 atf_add_test_case and_condition 896 atf_add_test_case or_condition 897 atf_add_test_case greaterthan 898 atf_add_test_case lesserthan 899 atf_add_test_case multiple_and_condition 900 atf_add_test_case multiple_or_condition 901 atf_add_test_case join 902 atf_add_test_case option_n 903 atf_add_test_case numeric_compare 904 atf_add_test_case remove_first_line 905 atf_add_test_case atmark 906 atf_add_test_case select 907 atf_add_test_case empty_output 908 atf_add_test_case zero 909 atf_add_test_case not_match 910 atf_add_test_case long 911 912 atf_add_test_case opt_s_empty 913 atf_add_test_case opt_s_a_with_eor 914 atf_add_test_case opt_s_a_without_eor 915 atf_add_test_case opt_s_fl_with_eor 916 atf_add_test_case opt_s_data_with_eor 917 atf_add_test_case opt_s_data_without_eor 918 atf_add_test_case opt_s_greaterthan 919 atf_add_test_case opt_s_lesserthan 920 atf_add_test_case opt_s_greaterthan_or_equal_to 921 atf_add_test_case opt_s_lesserthan_or_equal_to 922 atf_add_test_case opt_s_atmark 923 atf_add_test_case opt_s_not_match 924 atf_add_test_case opt_s_long 925} 926