From 0e65b89bd36567571cbcdee309ee97d1d4e81738 Mon Sep 17 00:00:00 2001 From: Naruto TAKAHASHI Date: Wed, 22 Aug 2018 00:47:57 +0900 Subject: [PATCH] add mynewt test script for jenkins. --- mynewt/.gitignore | 1 + mynewt/README.md | 19 +++++++++++ mynewt/jenkins.sh | 58 ++++++++++++++++++++++++++++++++ mynewt/test_client-tls.expect | 62 +++++++++++++++++++++++++++++++++++ mynewt/test_client-tls.sh | 22 ------------- 5 files changed, 140 insertions(+), 22 deletions(-) create mode 100644 mynewt/.gitignore create mode 100755 mynewt/jenkins.sh create mode 100755 mynewt/test_client-tls.expect delete mode 100644 mynewt/test_client-tls.sh diff --git a/mynewt/.gitignore b/mynewt/.gitignore new file mode 100644 index 00000000..3fec32c8 --- /dev/null +++ b/mynewt/.gitignore @@ -0,0 +1 @@ +tmp/ diff --git a/mynewt/README.md b/mynewt/README.md index 6b963fff..6620aa68 100644 --- a/mynewt/README.md +++ b/mynewt/README.md @@ -92,3 +92,22 @@ wolfssl read wolfssl clear net close ``` + +# jenkins script +## setup for jenkins node + +install below softwares + +- git +- expect +- bash +- screen +- [newt](https://mynewt.apache.org/latest/get_started/native_install/index.html)(v1.4.1 over) + +## Usage + +execute `jenkins.sh` script on jenkins. + +``` +./mynewt/jenkins.sh +``` diff --git a/mynewt/jenkins.sh b/mynewt/jenkins.sh new file mode 100755 index 00000000..2e26a8c5 --- /dev/null +++ b/mynewt/jenkins.sh @@ -0,0 +1,58 @@ +#!/bin/bash -ex + +BASEDIR=`dirname $0` +BASEDIR=`cd $BASEDIR && pwd -P` + +# kill previous process +set +e +killall -9 wolfsslclienttlsmn.elf +set -e + +pushd ${BASEDIR} > /dev/null + +/bin/rm -rf tmp +/bin/mkdir tmp +pushd tmp > /dev/null + +# create mynewt project +newt new myproj +NEWTPROJ=`pwd`/myproj +pushd ${NEWTPROJ} > /dev/null +newt upgrade +popd > /dev/null + +# deploy wolfssl source files to mynewt project +git clone https://github.com/wolfSSL/wolfssl.git +WOLFSSL=`pwd`/wolfssl +${WOLFSSL}/IDE/mynewt/setup.sh ${NEWTPROJ} + +# deploy wolfssl example source files to mynewt project +${BASEDIR}/setup.sh ${NEWTPROJ} + +# build sample program +pushd ${NEWTPROJ} > /dev/null +newt target create wolfsslclienttlsmn_sim +newt target set wolfsslclienttlsmn_sim app=apps/wolfsslclienttlsmn +newt target set wolfsslclienttlsmn_sim bsp=@apache-mynewt-core/hw/bsp/native +newt target set wolfsslclienttlsmn_sim build_profile=debug +newt build wolfsslclienttlsmn_sim + +/bin/rm -f wolfsslclienttlsmn.log +(./bin/targets/wolfsslclienttlsmn_sim/app/apps/wolfsslclienttlsmn/wolfsslclienttlsmn.elf &) > wolfsslclienttlsmn.log +sleep 1 +TTY_NAME=`cat wolfsslclienttlsmn.log | cut -d ' ' -f 3` + +expect ${BASEDIR}/test_client-tls.expect $TTY_NAME + +killall -9 wolfsslclienttlsmn.elf + +popd > /dev/null + +popd > /dev/null # tmp + +# cleanup tmp directory on jenkins +if [ ! -z "$JENKINS_URL" ]; then + /bin/rm -rf tmp +fi + +popd > /dev/null # ${BASEDIR} diff --git a/mynewt/test_client-tls.expect b/mynewt/test_client-tls.expect new file mode 100755 index 00000000..570213a1 --- /dev/null +++ b/mynewt/test_client-tls.expect @@ -0,0 +1,62 @@ +#!/usr/bin/env expect + +set timeout 10 + +set tty [lindex $argv 0] +spawn screen $tty + +send "\n" +expect { + timeout {exit 2} + -re ".* compat>" +} + +send "net tcp\n" +expect { + timeout {exit 3} + -re ".* mn_socket\\(TCP\\) = 0.*\n.* compat>" +} + +send "net connect\n" +expect { + timeout {exit 4} + -re ".* net_test_writable 0 - 0.*" +} + +send "wolfssl init\n" +expect { + timeout {exit 5} + -re ".* compat>" +} + +send "wolfssl connect\n" +expect { + timeout {exit 6} + -re ".* wolfSSL_connect\\(\\) = 1.*\n.* compat>" +} + +send "wolfssl write\n" +expect { + timeout {exit 7} + -re ".* wolfSSL_write\\(\\) = .*\n.* compat>" +} + +send "wolfssl read\n" +expect { + timeout {exit 8} + -re ".* compat>" +} + +send "wolfssl clear\n" +expect { + timeout {exit 9} + -re ".* compat>" +} + +send "net close\n" +expect { + timeout {exit 10} + -re ".* mn_close\\(\\) = 0.*\n.* compat>" +} + +exit 0 diff --git a/mynewt/test_client-tls.sh b/mynewt/test_client-tls.sh deleted file mode 100644 index 4b5cac65..00000000 --- a/mynewt/test_client-tls.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -e - -if [ $# -ne 1 ]; then - echo "$0 program_path" - exit 1 -fi -PROGRAM=$1 - -TIMEOUT=10 - -expect -c " - set timeout ${TIMEOUT} - spawn \"${PROGRAM}\" - expect -re {uart0 at (.*)} { - send $expect_out(1,string) - send $expect_out(0,string) - send $expect_out(2,string) - } - expect \"$\" - exit 0 -" -exit 0 \ No newline at end of file