device_type: soca9
job_name: SE ${MACHINE} prod-image (u-boot,nfs,wic) ${MANIFEST_BRANCH}-${KERNEL_VERSION_PATCHLEVEL} ${BUILD_NUMBER}

timeouts:
  job:
    minutes: 100
  action:
    minutes: 70
  connection:
    minutes: 20
priority: medium
visibility: public

actions:

##################
# Deploy WIC image
##################
- deploy:
    timeout:
      minutes: 20
    to: flasher
    images:
      image:
        url: ${WIC_IMAGE_URL}
        compression: bz2
      layout:
        url: ${WIC_BMAP_URL}


##########################
# Configure ethernet ports
##########################
- command:
    name: j17_off
- command:
    name: j21_on
- command:
    name: j22_off
- command:
    name: j23_off
- command:
    name: j24_off

###############
# u-boot
###############
- deploy:
    timeout:
      minutes: 15
    to: tftp
    kernel:
      # This is a known kernel image used for CRC checks only
      url: https://releases.linaro.org/members/schneider/openembedded/2019.09-warrior/soca9/zImage--4.19.72+git0+7549a49ae5-r0-snarc-soca9-20191003145415.bin
      type: zimage

- boot:
    timeout:
      minutes: 20
    method: bootloader
    bootloader: u-boot
    commands: []
    prompts: ["=>"]

# Run some U-Boot tests
- test:
    timeout:
      minutes: 5
    interactive:
    - name: uboot-tests
      prompts: ["=> ", "/ # "]
      script:
      - command: echo "u-boot echo test"
        name: echo
        successes:
        - message: "u-boot echo test"
      - command: version
        name: version
        successes:
        - message: "U-Boot"
      - command: help test
        name: help
        successes:
        - message: "test - minimal test like /bin/sh"
      # saveenv and printenv
      - command: setenv test_var test123
      - command: printenv
        name: setenv-and-printenv
        successes:
        - message: "test_var=test123"
    - name: memory-test
      prompts: ["=> ", "/ # "]
      script:
      # memory test
      # base - print or set address offset
      - command: base
        name: print-default-base-address-offset
        successes:
        - message: "Base Address: 0x"
      - command: base 00000000
        name: set-address-offset-0x00000000
        successes:
        - message: "Base Address: 0x00000000"
      - command: base
        name: check-address-offset-0x00000000
        successes:
        - message: "Base Address: 0x00000000"
      # crc32 - checksum calculation
      - command: mw.b 00000000 aa 400
      - command: crc32 -v 0 400 3c6f327d
      - command: echo return code $$?
        name: compute-CRC32-checksum
        successes:
        - message: "return code 0"
      # mw - memory write
      # md - memory display
      - command: mw 100000 aabbccdd 10
      - command: md 100000 10
        name: mw-md-100000
        successes:
        - message: "aabbccdd"
      # md - memory display
      # cp - memory copy
      - command: cp 100000 200000 10
      - command: md 200000 10
        name: cp-md-200000
        successes:
        - message: "aabbccdd"
      # cmp - memory compare
      - command: cmp 100000 200000 10
        name: cmp-100000-200000-10
        successes:
        - message: "Total of 16 word\\(s\\) were the same"
    - name: fpga-check-cmds
      prompts: ["=> ", "/ # "]
      script:
      # FPGA checksum and dump start and end of image
      - command: mw.b 0x01000000 0 0x700000
      - command: run scan_dev_for_fpga
      - command: crc32 0x01000000 006aebe4
      - command: '#'
      - command: md.b 0x01000000 100
      - command: '#'
      - command: md.b 016aea10 200
      - command: '#'
    - name: dhcp-cmds
      prompts: ["=> ", "/ # "]
      script:
      # dhcp
      - command: run FPGA_INIT
        successes:
        - message: "FPGA updated to correct revision."
        name: fpga_init
      - command: setenv autoload no ; dhcp ; dhcp
        name: dhcp
        successes:
        - message: "DHCP client bound to address"
    - name: ping-cmds
      prompts: ["=> ", "/ # "]
      script:
      # ping
      - command: ping {SERVER_IP}
        name: ping
        successes:
        - message: "is alive"
    - name: tftp-cmds
      prompts: ["=> ", "/ # "]
      script:
      # TFTP
      - command: setenv serverip {SERVER_IP} ; tftp {KERNEL_ADDR} {KERNEL}
        name: tftp
        successes:
        - message: "Bytes transferred = 6752784"
      - command: crc32 -v {KERNEL_ADDR} 670a10 ca050911
      - command: echo return code $$?
        successes:
        - message: "return code 0"


###############
# TFTP/NFS
###############
- deploy:
    timeout:
      minutes: 15
    to: tftp
    os: oe
    kernel:
      url: ${KERNEL_ZIMAGE_URL}
      type: zimage
    dtb:
      url: ${DTB_URL}
    nfsrootfs:
      url: ${NFSROOTFS_URL}
      compression: bz2

- boot:
    timeout:
      minutes: 20
    method: u-boot
    commands:
      - run FPGA_INIT
      - setenv autoload no
      - dhcp
      - dhcp
      - env print
      - setenv serverip {SERVER_IP}
      - tftp {KERNEL_ADDR} {KERNEL}
      - tftp 0x1000 {DTB}
      - "setenv bootargs 'console=ttyS0,115200n8 root=/dev/nfs rw nfsroot={NFS_SERVER_IP}:{NFSROOTFS},tcp,hard,intr,vers=3 rootwait coherent_pool=2M ip=dhcp'"
      - bootz 0x01000000 - 0x00001000
    auto_login:
      login_prompt: "login:"
      username: root
      password_prompt: "Password:"
      password: "P@ssword-1"
      login_commands:
      - "P@ssword-1"
      - "azertAZERT12345"
      - "azertAZERT12345"
      - "azertAZERT12345"
    prompts:
    - "Current password: "
    - "New password: "
    - "Retype new password: "
    - "root@snarc-soca9:"
    - "root@rzn1-snarc:"

- test:
    timeout:
      minutes: 10
    interactive:
    - name: basic-cmds-tftp
      prompts: ["root@snarc-soca9", "root@rzn1-snarc"]
      script:
      - command: uname -a
      - command: cat /proc/device-tree/model ; echo ""
      - command: ps aux --sort -rss
      - command: cat /proc/meminfo
      - command: cat /proc/cpuinfo
      - command: free -h
      - command: sysctl -a | grep vm.min_free_kbytes
      - command: mount
      - command: systemctl --no-pager status systemd-resolved
      - command: systemctl --no-pager restart systemd-resolved
      - command: systemctl --no-pager status systemd-resolved
      - command: ifconfig -a
      - command: ping -c 3 github.com
      - command: which docker
      - command: systemctl --no-pager status docker
      - command: sleep 100
      - command: systemctl --no-pager status docker
      - command: ifconfig -a
      - command: docker run hello-world
      - command: docker run -it ubuntu uname -a

- test:
    timeout:
      minutes: 20
    definitions:

    - name: smoke-tests-tftp
      from: git
      history: false
      repository: https://git.linaro.org/landing-teams/working/schneider/test-definitions.git
      branch: master
      path: automated/linux/smoke/smoke.yaml
      parameters:
        SKIP_INSTALL: True
        TESTS: "pwd, uname -a, cat /etc/os-release, ip a, lscpu, vmstat, lsblk, ps aux --sort -rss, free -h, mount"

    - name: ethernet-tftp
      from: git
      history: false
      repository: https://git.linaro.org/landing-teams/working/schneider/test-definitions.git
      branch: master
      path: automated/linux/ethernet/ethernet.yaml
      parameters:
        INTERFACE: eth1

    - name: meminfo-tftp
      from: git
      history: false
      repository: https://git.linaro.org/landing-teams/working/schneider/test-definitions.git
      branch: master
      path: automated/linux/meminfo/meminfo.yaml


###############
# prod-image.wic
###############
# We already flashed the SDcard WIC image in the deploy step at the begging of this test run
- boot:
    timeout:
      minutes: 10
    method: u-boot
    commands:
    - run linux_sd
    auto_login:
      login_prompt: "login:"
      username: root
      password_prompt: "Password:"
      password: "P@ssword-1"
      login_commands:
      - "P@ssword-1"
      - "azertAZERT12345"
      - "azertAZERT12345"
      - "azertAZERT12345"
    prompts:
    - "Current password: "
    - "New password: "
    - "Retype new password: "
    - "root@snarc-soca9:"
    - "root@rzn1-snarc:"

- test:
    timeout:
      minutes: 10
    interactive:
    - name: basic-cmds-wic
      prompts: ["root@snarc-soca9", "root@rzn1-snarc"]
      script:
      - command: uname -a
      - command: cat /proc/device-tree/model ; echo ""
      - command: mount
      - command: ps aux --sort -rss
      - command: cat /proc/meminfo
      - command: cat /proc/cpuinfo
      - command: free -h
      - command: sysctl -a | grep vm.min_free_kbytes
      - command: mount
      - command: systemctl --no-pager status systemd-resolved
      - command: systemctl --no-pager restart systemd-resolved
      - command: systemctl --no-pager status systemd-resolved
      - command: ifconfig -a
      - command: ping -c 3 github.com
      - command: which docker

metadata:
  machine: ${MACHINE}
  manifest branch: ${MANIFEST_BRANCH}-${KERNEL_VERSION_PATCHLEVEL}
  manifest commit: ${MANIFEST_COMMIT}
  build url: ${BUILD_URL}
  build location: ${PUBLISH_SERVER}${PUB_DEST}

notify:
    recipients:
    - to:
        method: email
        email: ralph.siemsen@linaro.org
    criteria:
        status: incomplete
    verbosity: verbose
