go.dedis.ch/onet/v3@v3.2.11-0.20210930124529-e36530bca7ef/dbadmin/test.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Usage:
     4  #   ./test [options]
     5  # Options:
     6  #   -b   re-builds bcadmin package
     7  
     8  DBG_TEST=1
     9  DBG_DA=1
    10  
    11  . "../app/libtest.sh"
    12  
    13  # This is constant as the 'dummy' creation uses always this db. It's the
    14  # sha256(ed25519.base)
    15  DUMMY_DB="01d0fabd251fcbbe2b93b4b927b26ad2a1a99077152e45ded1e678afa45dbec5.db"
    16  
    17  main(){
    18      startTest
    19      go build ../dummy
    20      runDummy --save
    21      run testInspect
    22      run testExtract
    23      run testMerge
    24      stopTest
    25  }
    26  
    27  testInspect(){
    28      testFail runDA inspect
    29      testFail runDA inspect dummy.db
    30      testFail runDA inspect --source dummy.db
    31      testGrep foo runDA inspect ${DUMMY_DB}
    32      testReGrep bar
    33      testGrep foo runDA inspect --source ${DUMMY_DB}
    34      testReGrep bar
    35  }
    36  
    37  testExtract(){
    38    testFail runDA extract
    39    testFail runDA extract --source dummy.db
    40    testFail runDA extract --source ${DUMMY_DB}
    41  
    42    TMPDB="tmp.db"
    43    rm -f ${TMPDB}
    44    testOK runDA extract --source ${DUMMY_DB} --destination ${TMPDB} Bar
    45    testGrep Bar runDA inspect ${TMPDB}
    46  
    47    rm -f ${TMPDB}
    48    testOK runDA extract --source ${DUMMY_DB} --destination ${TMPDB} Bar.*
    49    testGrep Bar runDA inspect ${TMPDB}
    50    testReGrep Bar_barDB
    51    testReGrep Barversion
    52  
    53    rm -f ${TMPDB}
    54    testOK runDA extract --source ${DUMMY_DB} --destination ${TMPDB}
    55    testGrep Bar runDA inspect ${TMPDB}
    56    testGrep Foo runDA inspect ${TMPDB}
    57  }
    58  
    59  testMerge(){
    60    TMPDB="tmp.db"
    61    MERGEDB="merge.db"
    62    rm -f ${TMPDB} ${MERGEDB}
    63  
    64    testOK runDA extract --source ${DUMMY_DB} --destination ${MERGEDB} Bar.*
    65    testNGrep Foo runDA inspect ${MERGEDB}
    66    testFail runDA extract --source ${DUMMY_DB} --destination ${MERGEDB} Foo.*
    67    testOK runDA extract --source ${DUMMY_DB} --destination ${MERGEDB} \
    68        --overwrite Foo.*
    69    testGrep Foo runDA inspect ${MERGEDB}
    70    testReGrep Foo_fooDB
    71    testReGrep Fooversion
    72  }
    73  
    74  runDA(){
    75      ./dbadmin --debug ${DBG_DA} "$@"
    76  }
    77  
    78  runDummy(){
    79      ./dummy "$@"
    80  }
    81  
    82  main