Hi Zeng!
On 08/01/2014 07:11 AM, Zeng Linggang wrote:
> * Move do_setup and do_cleanup into ftp_setup.
>
> * Delete ftp02_s1 and add do_test function for it.
>
> * Delete ftp_set_passwd and ftp_setup_vsftp_conf, since they are not be used.
>
> * Use test.sh instead of net_cmdlib.sh
>
> * Abandon trap and use tst_exit.
>
> * Make the test like:
>       (set TCID TST_TOTAL ...)
>       setup
>       do_test
>       check_result
>       tst_exit
>
> * Some cleanup.
>
> Signed-off-by: Zeng Linggang <zenglg...@cn.fujitsu.com>
> ---
>   testcases/network/tcp_cmds/ftp/ftp02               |  99 +++++++-----
>   testcases/network/tcp_cmds/ftp/ftp02_s1            |  71 ---------
>   testcases/network/tcp_cmds/ftp/ftp03               | 175 
> +++++++--------------
>   testcases/network/tcp_cmds/ftp/ftp04               | 109 ++++++-------
>   testcases/network/tcp_cmds/ftp/ftp05               | 146 ++++++++---------
>   testcases/network/tcp_cmds/ftp/ftp_set_passwd      |  28 ----
>   testcases/network/tcp_cmds/ftp/ftp_setup           |  73 +++++++++
>   .../network/tcp_cmds/ftp/ftp_setup_vsftp_conf      |   5 -
>   8 files changed, 304 insertions(+), 402 deletions(-)
>   delete mode 100755 testcases/network/tcp_cmds/ftp/ftp02_s1
>   delete mode 100755 testcases/network/tcp_cmds/ftp/ftp_set_passwd
>   create mode 100644 testcases/network/tcp_cmds/ftp/ftp_setup
>   delete mode 100755 testcases/network/tcp_cmds/ftp/ftp_setup_vsftp_conf
>
> diff --git a/testcases/network/tcp_cmds/ftp/ftp02 
> b/testcases/network/tcp_cmds/ftp/ftp02
> index 6d6e021..bb3139e 100755
> --- a/testcases/network/tcp_cmds/ftp/ftp02
> +++ b/testcases/network/tcp_cmds/ftp/ftp02
> @@ -28,59 +28,72 @@
>   #  NOTE:
>   #       This version is intended for EAL certification, it will need 
> modification
>   #       to conform with LTP standards in the offical LTP tree.
> +#
> +# DESCRIPTION:
> +#    Create Test User
> +#    Make sure test user cannont log in with invalid password
> +#    Cleanup Test User from system
> +#    Exit with exit code of script called upon
> +#
>   
> -#-----------------------------------------------------------------------
> -# FUNCTION:  do_setup
> -#-----------------------------------------------------------------------
> -
> -do_setup()
> +setup()
>   {
> +     tst_check_cmds expect ftp useradd userdel
> +     export TEST_USER="ftpuser2"
> +}
>   
> -    export RHOST="localhost"
> -    export TEST_USER="ftpuser2"
> -    export TEST_USER_PASSWD="eal"
> -    export TEST_USER_ENCRYPTED_PASSWD="42VmxaOByKwlA"
> -    export TEST_USER_HOMEDIR="/home/$TEST_USER"
> -
> -    # erase user if he may exist, so we can have a clean env
> -    TCtmp="/home/$TEST_USER"
> -
> -    tst_setup
> +do_test()
> +{
> +     CONNECTION_FAILED="Connection failed; test FAILED"
> +     EXPECTED="Login failed as expected; test PASSED"
> +     UNEXPECTED="Login succeeded unexpectedly; test FAILED"
>   
> -    exists expect ftp ftp02_s1 useradd userdel
> +     set PASSWD "invaild_password?!!"
> +     set timeout 90
>   
> -    userdel $TEST_USER
> -    sleep 1
> +     expect -c "
> +             #ftp to host
> +             spawn ftp $RHOST
> +             sleep 1
> +             # Check if connection succeeded.
> +             expect {
> +                     \"Name\" {}
> +                     timeout {send_user \"\n$CONNECTION_FAILED\n\";exit 1}
> +             }
>   
> -    if ! useradd -m -p $TEST_USER_ENCRYPTED_PASSWD $TEST_USER; then
> -        end_testcase "Could not add test user $TEST_USER to system $RHOST."
> -    fi
> +             send \"$RUSER\r\"
> +             sleep 1
> +             expect -re \"Password:\"
> +             send \"$PASSWD\r\"
> +             sleep 1
>   
> -    trap do_cleanup EXIT
> +             expect {
> +                     # 530 - Login failed
> +                     \"530\" {send_user \"$EXPECTED\n\";exit 0}
> +                     # 230 - Login successful
> +                     \"230\" {send_user \"$UNEXPECTED\n\"; exit 1}
> +             }
>   
> +             expect \"ftp>\"
> +             send \"exit\r\"
> +     "
>   }
>   
> -#-----------------------------------------------------------------------
> -# FUNCTION:  do_cleanup
> -#-----------------------------------------------------------------------
> +TCID="$0"

May be we should just change it to ftp02, otherwise test name will 
depend on how you running it (e.g. running by full path, TCID becomes 
"/opt/ltp/testcases/bin/test_name".

Are you running these tests from runEALtests.sh?

Can we add them to networktests.sh, to "TCP/IP command tests" group as 
it already has ftp01?

Thanks,
Alexey


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to