Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/testsuite/awk.tests

    r1765 r2725  
    11#!/bin/sh
    22
    3 # awk tests.
    43# Copyright 2007 by Denys Vlasenko <vda.linux@googlemail.com>
    5 # Licensed under GPL v2, see file LICENSE for details.
    6 
    7 . testing.sh
    8 
    9 # testing "description" "arguments" "result" "infile" "stdin"
     4# Licensed under GPLv2, see file LICENSE in this source tree.
     5
     6. ./testing.sh
     7
     8# testing "description" "command" "result" "infile" "stdin"
    109
    1110testing "awk -F case 0" "awk -F '[#]' '{ print NF }'" ""    "" ""
     
    1817testing "awk -F case 7" "awk -F '[#]' '{ print NF }'" "5\n" "" "z##abc##zz\n"
    1918
     19# 4294967295 = 0xffffffff
     20testing "awk bitwise op"  "awk '{ print or(4294967295,1) }'" "4.29497e+09\n" "" "\n"
     21optional DESKTOP
     22testing "awk hex const 1" "awk '{ print or(0xffffffff,1) }'" "4.29497e+09\n" "" "\n"
     23testing "awk hex const 2" "awk '{ print or(0x80000000,1) }'" "2.14748e+09\n" "" "\n"
     24testing "awk oct const"   "awk '{ print or(01234,1) }'"      "669\n"         "" "\n"
     25SKIP=
     26
     27# check that "hex/oct integer" heuristic doesn't kick in on 00NN.NNN
     28testing "awk floating const with leading zeroes" \
     29    "awk '{ printf \"%f %f\n\", \"000.123\", \"009.123\" }'" \
     30    "0.123000 9.123000\n" \
     31    "" "\n"
     32
     33# long field seps requiring regex
     34testing "awk long field sep" "awk -F-- '{ print NF, length(\$NF), \$NF }'" \
     35    "2 0 \n3 0 \n4 0 \n5 0 \n" \
     36    "" \
     37    "a--\na--b--\na--b--c--\na--b--c--d--"
     38
     39# '@(samp|code|file)\{' is an invalid extended regex (unmatched '{'),
     40# but gawk 3.1.5 does not bail out on it.
     41testing "awk gsub falls back to non-extended-regex" \
     42    "awk 'gsub(\"@(samp|code|file)\{\",\"\");'; echo \$?" "0\n" "" "Hi\n"
     43
     44optional TAR BUNZIP2 FEATURE_SEAMLESS_BZ2
     45test x"$SKIP" != x"1" && tar xjf awk_t1.tar.bz2
     46testing "awk 'gcc build bug'" \
     47    "awk -f awk_t1_opt-functions.awk -f awk_t1_opth-gen.awk <awk_t1_input | md5sum" \
     48    "f842e256461a5ab1ec60b58d16f1114f  -\n" \
     49    "" ""
     50rm -rf awk_t1_* 2>/dev/null
     51SKIP=
     52
     53Q='":"'
     54
     55testing "awk NF in BEGIN" \
     56    "awk 'BEGIN { print ${Q} NF ${Q} \$0 ${Q} \$1 ${Q} \$2 ${Q} }'" \
     57    ":0::::\n" \
     58    "" ""
     59
     60prg='
     61function b(tmp) {
     62    tmp = 0;
     63    print "" tmp; #this line causes the bug
     64    return tmp;
     65}
     66function c(tmpc) {
     67    tmpc = b(); return tmpc;
     68}
     69BEGIN {
     70    print (c() ? "string" : "number");
     71}'
     72testing "awk string cast (bug 725)" \
     73    "awk '$prg'" \
     74    "0\nnumber\n" \
     75    "" ""
     76
     77testing "awk handles whitespace before array subscript" \
     78    "awk 'BEGIN { arr [3] = 1; print arr [3] }'" "1\n" "" ""
     79
     80# GNU awk 3.1.5's "print ERRNO" prints "No such file or directory" instead of "2",
     81# do we need to emulate that as well?
     82testing "awk handles non-existing file correctly" \
     83    "awk 'BEGIN { getline line <\"doesnt_exist\"; print ERRNO; ERRNO=0; close(\"doesnt_exist\"); print ERRNO; print \"Ok\" }'" \
     84    "2\n0\nOk\n" "" ""
     85
     86prg='
     87BEGIN {
     88  u["a"]=1
     89  u["b"]=1
     90  u["c"]=1
     91  v["d"]=1
     92  v["e"]=1
     93  v["f"]=1
     94  for (l in u) {
     95    print "outer1", l;
     96    for (l in v) {
     97      print " inner", l;
     98    }
     99    print "outer2", l;
     100  }
     101  print "end", l;
     102  l="a"
     103  exit;
     104}'
     105testing "awk nested loops with the same variable" \
     106    "awk '$prg'" \
     107    "\
     108outer1 a
     109 inner d
     110 inner e
     111 inner f
     112outer2 f
     113outer1 b
     114 inner d
     115 inner e
     116 inner f
     117outer2 f
     118outer1 c
     119 inner d
     120 inner e
     121 inner f
     122outer2 f
     123end f
     124" \
     125    "" ""
     126
     127prg='
     128BEGIN {
     129  u["a"]=1
     130  u["b"]=1
     131  u["c"]=1
     132  v["d"]=1
     133  v["e"]=1
     134  v["f"]=1
     135  for (l in u) {
     136    print "outer1", l;
     137    for (l in v) {
     138      print " inner", l;
     139      break;
     140    }
     141    print "outer2", l;
     142  }
     143  print "end", l;
     144  l="a"
     145  exit;
     146}'
     147# It's not just buggy, it enters infinite loop. Thus disabled
     148false && test x"$SKIP_KNOWN_BUGS" = x"" && testing "awk nested loops with the same variable and break" \
     149    "awk '$prg'" \
     150    "\
     151outer1 a
     152 inner d
     153outer2 d
     154outer1 b
     155 inner d
     156outer2 d
     157outer1 c
     158 inner d
     159outer2 d
     160end d
     161" \
     162    "" ""
     163
     164prg='
     165function f() {
     166  for (l in v) {
     167    print " inner", l;
     168    return;
     169  }
     170}
     171
     172BEGIN {
     173  u["a"]=1
     174  u["b"]=1
     175  u["c"]=1
     176  v["d"]=1
     177  v["e"]=1
     178  v["f"]=1
     179  for (l in u) {
     180    print "outer1", l;
     181    f();
     182    print "outer2", l;
     183  }
     184  print "end", l;
     185  l="a"
     186  exit;
     187}'
     188# It's not just buggy, it enters infinite loop. Thus disabled
     189false && test x"$SKIP_KNOWN_BUGS" = x"" && testing "awk nested loops with the same variable and return" \
     190    "awk '$prg'" \
     191    "\
     192outer1 a
     193 inner d
     194outer2 d
     195outer1 b
     196 inner d
     197outer2 d
     198outer1 c
     199 inner d
     200outer2 d
     201end d
     202" \
     203    "" ""
     204
    20205exit $FAILCOUNT
Note: See TracChangeset for help on using the changeset viewer.