github.com/StackExchange/blackbox/v2@v2.0.1-0.20220331193400-d84e904973ab/tools/auto_system_test (about)

     1  #!/usr/bin/env expect
     2  
     3  # Run the confidence test non-interactively.  Since the script
     4  # asks for passphrases, we use "expect" to simulate keyboard data entry.
     5  
     6  # Run the test:
     7  spawn tools/confidence_test.sh
     8  
     9  # As we run the confidence test, respond with the right password.
    10  # We do this for up to 300 times to prevent an infinite loop.
    11  
    12  set times 0;
    13  while { $times < 300 } {
    14     expect {
    15         # The script outputs what the password will be, and we save
    16         # that info in $pw any time we see the text.
    17         "my password is the lowercase letter a" { set pw "a\n" ; exp_continue }
    18         "my password is the lowercase letter b" { set pw "b\n" ; exp_continue }
    19         # If the passphrase is requested, send it.
    20         "Passphrase:" { send $pw ; exp_continue }
    21         # If we reach EOF, exit this loop.
    22         eof { break }
    23     }
    24     set times [ expr $times+1];
    25  }