#!/bin/sh # # Copyright (c) 2007, Cameron Rich # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of the axTLS project nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # Test the various axssl bindings. To run it, got to the _install directory # and run this script from there. # if grep "CONFIG_PLATFORM_WIN32=y" "../config/.config" > /dev/null { global JAVA_EXE := ""$JAVA_HOME/bin/java.exe"" global PERL_BIN := '"/cygdrive/c/Perl/bin/perl'" global KILL_AXSSL := '"kill %1'" global KILL_CSHARP := '"kill %1'" global KILL_PERL := '"kill %1'" global KILL_JAVA := '"kill %1'" global KILL_LUA := '"kill %1'" } else { if grep "CONFIG_PLATFORM_CYGWIN=y" "../config/.config" > /dev/null { # no .net or java on cygwin global PERL_BIN := '/usr/bin/perl' global KILL_AXSSL := '"killall axssl'" global KILL_PERL := '"killall /usr/bin/perl'" global KILL_LUA := '"killall /usr/local/bin/lua'" } else { # Linux global JAVA_EXE := '/usr/java/default/bin/java' global PERL_BIN := '/usr/bin/perl' global KILL_AXSSL := '"killall axssl'" global KILL_CSHARP := '"killall mono'" global KILL_PERL := '"killall /usr/bin/perl'" global RUN_CSHARP := '"mono'" global KILL_JAVA := ""killall $JAVA_EXE"" global KILL_LUA := '"killall /usr/local/bin/lua'" } } global BASE := '..' global SERVER_ARGS := ""s_server -accept 15001 -verify -CAfile $BASE/ssl/test/axTLS.ca_x509.cer"" global CLIENT_ARGS := ""s_client -reconnect -connect localhost:15001 -verify -CAfile $BASE/ssl/test/axTLS.ca_x509.cer -key $BASE/ssl/test/axTLS.key_1024 -cert $BASE/ssl/test/axTLS.x509_1024.cer"" # check pem arguments global SERVER_PEM_ARGS := ""s_server -accept 15001 -pass abcd -key $BASE/ssl/test/axTLS.key_aes128.pem -cert $BASE/ssl/test/axTLS.x509_aes128.pem"" global CLIENT_PEM_ARGS := ""s_client -connect localhost:15001 -CAfile $BASE/ssl/test/axTLS.ca_x509.pem -key $BASE/ssl/test/axTLS.key_1024.pem -cert $BASE/ssl/test/axTLS.x509_1024.pem"" export LD_LIBRARY_PATH=.:$[perl -e 'use Config; print $Config{archlib};]/CORE if test -x ./axssl { echo "############################# C SAMPLE ###########################" ./axssl $SERVER_ARGS & echo "C Test passed" | ./axssl $CLIENT_ARGS $KILL_AXSSL sleep 1 ./axssl $SERVER_PEM_ARGS & echo "C Test passed" | ./axssl $CLIENT_PEM_ARGS $KILL_AXSSL sleep 1 echo "### C tests complete" } if test -f ./axtls.jar { echo "########################## JAVA SAMPLE ###########################" $JAVA_EXE -jar ./axtls.jar $SERVER_ARGS & echo "Java Test passed" | $JAVA_EXE -jar ./axtls.jar $CLIENT_ARGS $KILL_JAVA sleep 1 $JAVA_EXE -jar ./axtls.jar $SERVER_PEM_ARGS & echo "Java Test passed" | $JAVA_EXE -jar ./axtls.jar $CLIENT_PEM_ARGS $KILL_JAVA sleep 1 echo "### Java tests complete" } if test -x ./axssl.csharp.exe { echo "############################ C# SAMPLE ###########################" $RUN_CSHARP ./axssl.csharp.exe $SERVER_ARGS & echo "C# Test passed" | $RUN_CSHARP ./axssl.csharp.exe $CLIENT_ARGS $KILL_CSHARP sleep 1 $RUN_CSHARP ./axssl.csharp.exe $SERVER_PEM_ARGS & echo "C# Test passed" | $RUN_CSHARP ./axssl.csharp.exe $CLIENT_PEM_ARGS $KILL_CSHARP sleep 1 echo "### C# tests complete" } if test -x ./axssl.vbnet.exe { echo "######################## VB.NET SAMPLE ###########################" echo $SERVER_ARGS echo $CLIENT_ARGS ./axssl.vbnet $SERVER_ARGS & echo "VB.NET Test passed" | ./axssl.vbnet.exe $CLIENT_ARGS kill %1 sleep 1 ./axssl.vbnet $SERVER_PEM_ARGS & echo "VB.NET Test passed" | ./axssl.vbnet.exe $CLIENT_PEM_ARGS kill %1 sleep 1 echo "### VB.NET tests complete" } if test -f ./axssl.pl { echo "########################## PERL SAMPLE ###########################" $PERL_BIN ./axssl.pl $SERVER_ARGS & echo "Perl Test passed" | $PERL_BIN ./axssl.pl $CLIENT_ARGS $KILL_PERL sleep 1 $PERL_BIN ./axssl.pl $SERVER_PEM_ARGS & echo "Perl Test passed" | $PERL_BIN ./axssl.pl $CLIENT_PEM_ARGS $KILL_PERL sleep 1 echo "### Perl tests complete" } if test -f ./axssl.lua { echo "########################## LUA SAMPLE ###########################" ./axssl.lua $SERVER_ARGS & echo "Lua Test passed" | ./axssl.lua $CLIENT_ARGS $KILL_LUA sleep 1 ./axssl.lua $SERVER_PEM_ARGS & echo "Lua Test passed" | ./axssl.lua $CLIENT_PEM_ARGS $KILL_LUA sleep 1 echo "### Lua tests complete" } echo "########################## ALL TESTS COMPLETE ###########################" (CommandList children: [ (If arms: [ (if_arm cond: [ (Sentence child: (SimpleCommand words: [{(grep)} {(DQ ("CONFIG_PLATFORM_WIN32=y"))} {(DQ (../config/.config))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[117])] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:JAVA_EXE) op: Equal rhs: {(DQ ($ VSub_Name "$JAVA_HOME") (/bin/java.exe))} spids: [125] ) ] spids: [125] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PERL_BIN) op: Equal rhs: {(DQ (/cygdrive/c/Perl/bin/perl))} spids: [132] ) ] spids: [132] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_AXSSL) op: Equal rhs: {(DQ ("kill %1"))} spids: [138] ) ] spids: [138] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_CSHARP) op: Equal rhs: {(DQ ("kill %1"))} spids: [144] ) ] spids: [144] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_PERL) op: Equal rhs: {(DQ ("kill %1"))} spids: [150] ) ] spids: [150] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_JAVA) op: Equal rhs: {(DQ ("kill %1"))} spids: [156] ) ] spids: [156] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_LUA) op: Equal rhs: {(DQ ("kill %1"))} spids: [162] ) ] spids: [162] ) ] spids: [-1 122] ) ] else_action: [ (If arms: [ (if_arm cond: [ (Sentence child: (SimpleCommand words: [{(grep)} {(DQ ("CONFIG_PLATFORM_CYGWIN=y"))} {(DQ (../config/.config))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[182])] ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PERL_BIN) op: Equal rhs: {(/usr/bin/perl)} spids: [194] ) ] spids: [194] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_AXSSL) op: Equal rhs: {(DQ ("killall axssl"))} spids: [198] ) ] spids: [198] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_PERL) op: Equal rhs: {(DQ ("killall /usr/bin/perl"))} spids: [204] ) ] spids: [204] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_LUA) op: Equal rhs: {(DQ ("killall /usr/local/bin/lua"))} spids: [210] ) ] spids: [210] ) ] spids: [-1 187] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:JAVA_EXE) op: Equal rhs: {(/usr/java/default/bin/java)} spids: [222] ) ] spids: [222] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PERL_BIN) op: Equal rhs: {(/usr/bin/perl)} spids: [226] ) ] spids: [226] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_AXSSL) op: Equal rhs: {(DQ ("killall axssl"))} spids: [230] ) ] spids: [230] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_CSHARP) op: Equal rhs: {(DQ ("killall mono"))} spids: [236] ) ] spids: [236] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_PERL) op: Equal rhs: {(DQ ("killall /usr/bin/perl"))} spids: [242] ) ] spids: [242] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:RUN_CSHARP) op: Equal rhs: {(DQ (mono))} spids: [248] ) ] spids: [248] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_JAVA) op: Equal rhs: {(DQ ("killall ") ($ VSub_Name "$JAVA_EXE"))} spids: [254] ) ] spids: [254] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KILL_LUA) op: Equal rhs: {(DQ ("killall /usr/local/bin/lua"))} spids: [261] ) ] spids: [261] ) ] spids: [216 267] ) ] spids: [167 269] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:BASE) op:Equal rhs:{(..)} spids:[272])] spids: [272] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SERVER_ARGS) op: Equal rhs: { (DQ ("s_server -accept 15001 -verify -CAfile ") ($ VSub_Name "$BASE") (/ssl/test/axTLS.ca_x509.cer) ) } spids: [275] ) ] spids: [275] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CLIENT_ARGS) op: Equal rhs: { (DQ ("s_client -reconnect -connect localhost:15001 -verify -CAfile ") ($ VSub_Name "$BASE") ("/ssl/test/axTLS.ca_x509.cer -key ") ($ VSub_Name "$BASE") ("/ssl/test/axTLS.key_1024 -cert ") ($ VSub_Name "$BASE") (/ssl/test/axTLS.x509_1024.cer) ) } spids: [282] ) ] spids: [282] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SERVER_PEM_ARGS) op: Equal rhs: { (DQ ("s_server -accept 15001 -pass abcd -key ") ($ VSub_Name "$BASE") ("/ssl/test/axTLS.key_aes128.pem -cert ") ($ VSub_Name "$BASE") (/ssl/test/axTLS.x509_aes128.pem) ) } spids: [297] ) ] spids: [297] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CLIENT_PEM_ARGS) op: Equal rhs: { (DQ ("s_client -connect localhost:15001 -CAfile ") ($ VSub_Name "$BASE") ("/ssl/test/axTLS.ca_x509.pem -key ") ($ VSub_Name "$BASE") ("/ssl/test/axTLS.key_1024.pem -cert ") ($ VSub_Name "$BASE") (/ssl/test/axTLS.x509_1024.pem) ) } spids: [306] ) ] spids: [306] ) (C {(export)} {(Lit_VarLike "LD_LIBRARY_PATH=") (.) (Lit_Other ":") (CommandSubPart command_list: (CommandList children: [(C {(perl)} {(-e)} {(SQ <"use Config; print $Config{archlib};">)})] ) left_token: spids: [323 331] ) (/CORE) } ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-x)} {(./axssl)} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} {(DQ ("############################# C SAMPLE ###########################"))}) (Sentence child: (C {(./axssl)} {($ VSub_Name "$SERVER_ARGS")}) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("C Test passed"))}) (C {(./axssl)} {($ VSub_Name "$CLIENT_ARGS")}) ] negated: False ) (C {($ VSub_Name "$KILL_AXSSL")}) (C {(sleep)} {(1)}) (Sentence child: (C {(./axssl)} {($ VSub_Name "$SERVER_PEM_ARGS")}) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("C Test passed"))}) (C {(./axssl)} {($ VSub_Name "$CLIENT_PEM_ARGS")}) ] negated: False ) (C {($ VSub_Name "$KILL_AXSSL")}) (C {(sleep)} {(1)}) (C {(echo)} {(DQ ("### C tests complete"))}) ] spids: [-1 346] ) ] spids: [-1 409] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-f)} {(./axtls.jar)} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} {(DQ ("########################## JAVA SAMPLE ###########################"))}) (Sentence child: (C {(DQ ($ VSub_Name "$JAVA_EXE"))} {(-jar)} {(./axtls.jar)} {($ VSub_Name "$SERVER_ARGS")} ) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("Java Test passed"))}) (C {(DQ ($ VSub_Name "$JAVA_EXE"))} {(-jar)} {(./axtls.jar)} {($ VSub_Name "$CLIENT_ARGS")} ) ] negated: False ) (C {($ VSub_Name "$KILL_JAVA")}) (C {(sleep)} {(1)}) (Sentence child: (C {(DQ ($ VSub_Name "$JAVA_EXE"))} {(-jar)} {(./axtls.jar)} {($ VSub_Name "$SERVER_PEM_ARGS")} ) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("Java Test passed"))}) (C {(DQ ($ VSub_Name "$JAVA_EXE"))} {(-jar)} {(./axtls.jar)} {($ VSub_Name "$CLIENT_PEM_ARGS")} ) ] negated: False ) (C {($ VSub_Name "$KILL_JAVA")}) (C {(sleep)} {(1)}) (C {(echo)} {(DQ ("### Java tests complete"))}) ] spids: [-1 423] ) ] spids: [-1 511] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-x)} {(./axssl.csharp.exe)} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} {(DQ ("############################ C# SAMPLE ###########################"))}) (Sentence child: (C {($ VSub_Name "$RUN_CSHARP")} {(./axssl.csharp.exe)} {($ VSub_Name "$SERVER_ARGS")}) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("C# Test passed"))}) (C {($ VSub_Name "$RUN_CSHARP")} {(./axssl.csharp.exe)} {($ VSub_Name "$CLIENT_ARGS")}) ] negated: False ) (C {($ VSub_Name "$KILL_CSHARP")}) (C {(sleep)} {(1)}) (Sentence child: (C {($ VSub_Name "$RUN_CSHARP")} {(./axssl.csharp.exe)} {($ VSub_Name "$SERVER_PEM_ARGS")} ) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("C# Test passed"))}) (C {($ VSub_Name "$RUN_CSHARP")} {(./axssl.csharp.exe)} {($ VSub_Name "$CLIENT_PEM_ARGS")} ) ] negated: False ) (C {($ VSub_Name "$KILL_CSHARP")}) (C {(sleep)} {(1)}) (C {(echo)} {(DQ ("### C# tests complete"))}) ] spids: [-1 525] ) ] spids: [-1 597] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-x)} {(./axssl.vbnet.exe)} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} {(DQ ("######################## VB.NET SAMPLE ###########################"))}) (C {(echo)} {($ VSub_Name "$SERVER_ARGS")}) (C {(echo)} {($ VSub_Name "$CLIENT_ARGS")}) (Sentence child: (C {(./axssl.vbnet)} {($ VSub_Name "$SERVER_ARGS")}) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("VB.NET Test passed"))}) (C {(./axssl.vbnet.exe)} {($ VSub_Name "$CLIENT_ARGS")}) ] negated: False ) (C {(kill)} {(Lit_Other "%") (1)}) (C {(sleep)} {(1)}) (Sentence child: (C {(./axssl.vbnet)} {($ VSub_Name "$SERVER_PEM_ARGS")}) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("VB.NET Test passed"))}) (C {(./axssl.vbnet.exe)} {($ VSub_Name "$CLIENT_PEM_ARGS")}) ] negated: False ) (C {(kill)} {(Lit_Other "%") (1)}) (C {(sleep)} {(1)}) (C {(echo)} {(DQ ("### VB.NET tests complete"))}) ] spids: [-1 611] ) ] spids: [-1 688] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-f)} {(./axssl.pl)} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} {(DQ ("########################## PERL SAMPLE ###########################"))}) (Sentence child: (C {(DQ ($ VSub_Name "$PERL_BIN"))} {(./axssl.pl)} {($ VSub_Name "$SERVER_ARGS")}) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("Perl Test passed"))}) (C {(DQ ($ VSub_Name "$PERL_BIN"))} {(./axssl.pl)} {($ VSub_Name "$CLIENT_ARGS")}) ] negated: False ) (C {($ VSub_Name "$KILL_PERL")}) (C {(sleep)} {(1)}) (Sentence child: (C {(DQ ($ VSub_Name "$PERL_BIN"))} {(./axssl.pl)} {($ VSub_Name "$SERVER_PEM_ARGS")}) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("Perl Test passed"))}) (C {(DQ ($ VSub_Name "$PERL_BIN"))} {(./axssl.pl)} {($ VSub_Name "$CLIENT_PEM_ARGS")}) ] negated: False ) (C {($ VSub_Name "$KILL_PERL")}) (C {(sleep)} {(1)}) (C {(echo)} {(DQ ("### Perl tests complete"))}) ] spids: [-1 702] ) ] spids: [-1 781] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-f)} {(./axssl.lua)} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} {(DQ ("########################## LUA SAMPLE ###########################"))}) (Sentence child: (C {(./axssl.lua)} {($ VSub_Name "$SERVER_ARGS")}) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("Lua Test passed"))}) (C {(./axssl.lua)} {($ VSub_Name "$CLIENT_ARGS")}) ] negated: False ) (C {($ VSub_Name "$KILL_LUA")}) (C {(sleep)} {(1)}) (Sentence child: (C {(./axssl.lua)} {($ VSub_Name "$SERVER_PEM_ARGS")}) terminator: ) (Pipeline children: [ (C {(echo)} {(DQ ("Lua Test passed"))}) (C {(./axssl.lua)} {($ VSub_Name "$CLIENT_PEM_ARGS")}) ] negated: False ) (C {($ VSub_Name "$KILL_LUA")}) (C {(sleep)} {(1)}) (C {(echo)} {(DQ ("### Lua tests complete"))}) ] spids: [-1 795] ) ] spids: [-1 858] ) (C {(echo)} {(DQ ("########################## ALL TESTS COMPLETE ###########################"))}) ] )