#!/bin/sh # Copyright 2008 by Denys Vlasenko # Licensed under GPLv2, see file LICENSE in this source tree. . ./testing.sh COLLAPSE=$(( 0x00010000)) TRIM=$(( 0x00020000)) GREEDY=$(( 0x00040000)) MIN_DIE=$(( 0x00100000)) KEEP_COPY=$(( 0x00200000)) EOL_COMMENTS=$((0x00400000)) NORMAL=$(( COLLAPSE | TRIM | GREEDY | EOL_COMMENTS)) # testing "description" "command" "result" "infile" "stdin" testing "parse mdev.conf" \ "parse -n 4 -m 3 -f $((NORMAL)) -" \ "[sda][0:0][644][@echo @echo TEST]\n" \ "-" \ " sda 0:0 644 @echo @echo TEST # echo trap\n" testing "parse notrim" \ "parse -n 4 -m 3 -f $((NORMAL - TRIM - COLLAPSE)) -" \ "[][sda][0:0][644 @echo @echo TEST ]\n" \ "-" \ " sda 0:0 644 @echo @echo TEST \n" testing "parse comments" \ "parse -n 4 -m 3 -f $((NORMAL - EOL_COMMENTS)) -" \ "[sda][0:0][644][@echo @echo TEST #this is not eaten]\n" \ "-" \ "\ # sda 0:0 644 @echo @echo TEST - this gets eaten sda 0:0 644 @echo @echo TEST #this is not eaten " testing "parse bad comment" \ "parse -n 2 -m 2 -d '#=' -f $((GREEDY)) - 2>&1" \ "\ [var][val] parse: bad line 3: 1 tokens found, 2 needed [ #this][ok] [ #this][=ok] [ #this][=ok=ok=ok=] " \ "-" \ "\ # this gets eaten var=val #this causes error msg #this=ok #this==ok #this==ok=ok=ok= " FILE=__parse cat >$FILE <$FILE.res <$FILE.res <$FILE.res <