| // RUN: ( flags_demo ) | FileCheck --check-prefix=NO-FLAGS %s |
| // NO-FLAGS: FLAG[test_bool] = false |
| // NO-FLAGS: FLAG[test_int32] = 123 |
| // NO-FLAGS: FLAG[test_int64] = 555 |
| // NO-FLAGS: FLAG[test_float] = 1 |
| // NO-FLAGS: FLAG[test_string] = some default |
| // NO-FLAGS: FLAG[test_callback] = 0 |
| // NO-FLAGS: ARG(0) ={{.+}}flags_demo |
| |
| // RUN: ( flags_demo --help ) | FileCheck --check-prefix=FLAGS-HELP %s |
| // FLAGS-HELP: # {{.+}} IREE |
| // FLAGS-HELP: # Flags in {{.+}}flags.c |
| // FLAGS-HELP: # Displays command line usage information. |
| // FLAGS-HELP: --help |
| // FLAGS-HELP: # Flags in {{.+}}flags_demo.c |
| // FLAGS-HELP: # A boolean value. |
| // FLAGS-HELP: --test_bool=false |
| // FLAGS-HELP: # An int32_t value. |
| // FLAGS-HELP: --test_int32=123 |
| // FLAGS-HELP: # An int64_t value. |
| // FLAGS-HELP: --test_int64=555 |
| // FLAGS-HELP: # A float value. |
| // FLAGS-HELP: --test_float=1 |
| // FLAGS-HELP: # A string |
| // FLAGS-HELP: # value. |
| // FLAGS-HELP: --test_string="some default" |
| // FLAGS-HELP: # Callback! |
| // FLAGS-HELP: --test_callback=0 |
| |
| // RUN: ( flags_demo --unknown-flag 2>&1 || [[ $? == 1 ]] ) | FileCheck --check-prefix=UNKNOWN-FLAG %s |
| // UNKNOWN-FLAG: INVALID_ARGUMENT; flag 'unknown-flag' not recognized |
| |
| // RUN: ( flags_demo --test_bool=true ) | FileCheck --check-prefix=FLAG-BOOL-TRUE %s |
| // FLAG-BOOL-TRUE: FLAG[test_bool] = true |
| // RUN: ( flags_demo --test_bool=1 ) | FileCheck --check-prefix=FLAG-BOOL-1 %s |
| // FLAG-BOOL-1: FLAG[test_bool] = true |
| // RUN: ( flags_demo --test_bool=true --test_bool=false ) | FileCheck --check-prefix=FLAG-BOOL-OVERRIDE %s |
| // FLAG-BOOL-OVERRIDE: FLAG[test_bool] = false |
| |
| // RUN: ( flags_demo --test_int32=456 ) | FileCheck --check-prefix=FLAG-INT32 %s |
| // FLAG-INT32: FLAG[test_int32] = 456 |
| // RUN: ( flags_demo --test_int32=-2147483648 ) | FileCheck --check-prefix=FLAG-INT32-MIN %s |
| // FLAG-INT32-MIN: FLAG[test_int32] = -2147483648 |
| // RUN: ( flags_demo --test_int32=2147483647 ) | FileCheck --check-prefix=FLAG-INT32-MAX %s |
| // FLAG-INT32-MAX: FLAG[test_int32] = 2147483647 |
| |
| // RUN: ( flags_demo --test_int64=902834 ) | FileCheck --check-prefix=FLAG-INT64 %s |
| // FLAG-INT64: FLAG[test_int64] = 902834 |
| // RUN: ( flags_demo --test_int64=-9223372036854775808 ) | FileCheck --check-prefix=FLAG-INT64-MIN %s |
| // FLAG-INT64-MIN: FLAG[test_int64] = -9223372036854775808 |
| // RUN: ( flags_demo --test_int64=9223372036854775807 ) | FileCheck --check-prefix=FLAG-INT64-MAX %s |
| // FLAG-INT64-MAX: FLAG[test_int64] = 9223372036854775807 |
| |
| // RUN: ( flags_demo --test_float=1.1234 ) | FileCheck --check-prefix=FLAG-FLOAT %s |
| // FLAG-FLOAT: FLAG[test_float] = 1.1234 |
| |
| // RUN: ( flags_demo --test_string= ) | FileCheck --check-prefix=FLAG-STRING-EMPTY %s |
| // FLAG-STRING-EMPTY: FLAG[test_string] = |
| // RUN: ( flags_demo --test_string=abc ) | FileCheck --check-prefix=FLAG-STRING-ABC %s |
| // FLAG-STRING-ABC: FLAG[test_string] = abc |
| // RUN: ( flags_demo --test_string="with some space" ) | FileCheck --check-prefix=FLAG-STRING-SPACES %s |
| // FLAG-STRING-SPACES: FLAG[test_string] = with some space |
| |
| // RUN: ( flags_demo --test_callback=1 ) | FileCheck --check-prefix=FLAG-CALLBACK-1 %s |
| // FLAG-CALLBACK-1: FLAG[test_callback] = 1 |
| // RUN: ( flags_demo --test_callback=4 ) | FileCheck --check-prefix=FLAG-CALLBACK-4 %s |
| // FLAG-CALLBACK-4: FLAG[test_callback] = 4 |
| // RUN: ( flags_demo --test_callback=FORCE_FAILURE 2>&1 || [[ $? == 1 ]] ) | FileCheck --check-prefix=FLAG-CALLBACK-ERROR %s |
| // FLAG-CALLBACK-ERROR: INTERNAL; callbacks can do verification |
| |
| // RUN: ( flags_demo ) | FileCheck --check-prefix=FLAG-LIST-0 %s |
| // FLAG-LIST-0: FLAG[test_strings] = 0 |
| // RUN: ( flags_demo --test_strings=a ) | FileCheck --check-prefix=FLAG-LIST-1 %s |
| // FLAG-LIST-1: FLAG[test_strings] = 1: a |
| // RUN: ( flags_demo --test_strings=a --test_strings=b ) | FileCheck --check-prefix=FLAG-LIST-2 %s |
| // FLAG-LIST-2: FLAG[test_strings] = 2: a, b |
| // RUN: ( flags_demo --test_strings=a --test_strings=b --test_strings=c ) | FileCheck --check-prefix=FLAG-LIST-3 %s |
| // FLAG-LIST-3: FLAG[test_strings] = 3: a, b, c |
| // RUN: ( flags_demo --test_strings=a --test_strings=b --test_strings=c --test_strings=d ) | FileCheck --check-prefix=FLAG-LIST-4 %s |
| // FLAG-LIST-4: FLAG[test_strings] = 4: a, b, c, d |
| // RUN: ( flags_demo --test_strings=a --test_strings=b --test_strings=c --test_strings=d --test_strings=e ) | FileCheck --check-prefix=FLAG-LIST-5 %s |
| // FLAG-LIST-5: FLAG[test_strings] = 5: a, b, c, d, e |
| |
| // RUN: ( flags_demo arg1 ) | FileCheck --check-prefix=FLAG-POSITIONAL-1 %s |
| // FLAG-POSITIONAL-1: ARG(1) = arg1 |
| // RUN: ( flags_demo arg1 arg2 arg3 ) | FileCheck --check-prefix=FLAG-POSITIONAL-3 %s |
| // FLAG-POSITIONAL-3: ARG(1) = arg1 |
| // FLAG-POSITIONAL-3: ARG(2) = arg2 |
| // FLAG-POSITIONAL-3: ARG(3) = arg3 |
| |
| // RUN: ( flags_demo --test_bool=true --flagfile=not_found.txt 2>&1 || [[ $? == 1 ]] ) | FileCheck --check-prefix=MISSING-FLAGFILE %s |
| // MISSING-FLAGFILE: NOT_FOUND; failed to open file 'not_found.txt' |
| |
| // RUN: ( flags_demo --test_bool=true --flagfile=%s ) | FileCheck --check-prefix=FLAGFILE %s |
| # Comments are ignored. |
| // FLAGFILE: FLAG[test_bool] = false |
| --test_bool=false |
| // FLAGFILE: FLAG[test_int64] = 123111 |
| // Note that whitespace is ignored in case you are copy/pasting flags around. |
| --test_int64=123111 |
| // FLAGFILE: FLAG[test_float] = 55.1 |
| --test_float=55.1 |
| // FLAGFILE: FLAG[test_string] = override spaces |
| --test_string="override spaces" |
| |
| |
| # NOTE: above two lines are to test that vertical whitespace is ok. |