timeouts:
  job:
    minutes: 140
  connection:
    minutes: 2
context:
  test_character_delay: 10
device_type: hi6220-hikey-r2
job_name: hikey - LKFT-like deployment of Linux 4.9
priority: 25
visibility: public
metadata:
  source: https://lkft.validation.linaro.org/scheduler/job/1295576/definition
protocols:
  lava-lxc:
    name: lxc-target
    template: debian
    distribution: debian
    release: buster
    arch: amd64
    mirror: http://deb.debian.org/debian

actions:

  - deploy:
      namespace: tlxc
      timeout:
        minutes: 15
      to: lxc
      packages:
        - wget
        - unzip
        - android-tools-fsutils
        - curl
        - cpio
        - file
        - git
        - libguestfs-tools
        - linux-image-amd64
        - mkbootimg
        - xz-utils
        - --no-install-recommends
      os: debian

  - boot:
      namespace: tlxc
      prompts:
      - root@(.*):/#
      timeout:
        minutes: 5
      method: lxc

  - test:
      namespace: tlxc
      timeout:
        minutes: 10
      definitions:
      - repository: https://github.com/Linaro/test-definitions.git
        from: git
        path: automated/linux/android-platform-tools/install.yaml
        name: install-android-platform-tools-r2800
        parameters:
          LINK: https://dl.google.com/android/repository/platform-tools_r28.0.0-linux.zip

  - deploy:
      timeout:
        minutes: 40
      to: download
      namespace: target
      images:
        ptable:
          url: http://localhost:8888/oe/hikey-4.9/ptable-linux-8g.img
        boot:
          url: http://localhost:8888/oe/hikey-4.9/boot-0.0+AUTOINC+2d8c108bf0-ed8112606c-r0-hikey-20200127231900-9.uefi.img
        dtb:
          url: http://localhost:8888/oe/hikey-4.9/hi6220-hikey.dtb
        kernel:
          url: http://localhost:8888/oe/hikey-4.9/Image
        modules:
          url: http://localhost:8888/oe/hikey-4.9/modules.tar.xz
        rootfs:
          url: http://localhost:8888/oe/hikey-4.9/rpb-console-image-lkft-hikey-20200205141751-9.rootfs.ext4.gz
          apply-overlay: true
      os: oe

  - test:
      namespace: tlxc
      timeout:
        minutes: 60
      definitions:
      - from: inline
        name: kir
        path: inline/kir.yaml
        repository:
          metadata:
            description: Squash kernel, dtb and modules into rootfs
            format: Lava-Test Test Definition 1.0
            name: resize-rootfs
          run:
            steps:
            - pwd
            - cd /lava-lxc
            - git clone -b 20200115 https://github.com/linaro/kir.git
            - ./kir/lava/board_setup.sh hi6220-hikey

  - deploy:
      timeout:
        minutes: 40
      to: fastboot
      namespace: target
      images:
        ptable:
          url: lxc:///ptable-linux-8g.img
          reboot: hard-reset
        boot:
          url: lxc:///boot.img
          reboot: hard-reset
        system:
          url: lxc:///rpb-console-image-lkft.rootfs.img
          apply-overlay: true
      os: oe
      protocols:
        lava-lxc:
        - action: fastboot-deploy
          request: pre-power-command
          timeout:
            minutes: 2

  - boot:
      namespace: target
      method: grub
      commands: installed
      auto_login:
        login_prompt: 'login:'
        username: linaro
        login_commands:
          # Become super user to run tests
          - su
      prompts:
        - hikey:~
        - hikey:/home/linaro#
        - root@(.*):[/~]#
      timeout:
        minutes: 10
      protocols:
        lava-lxc:
        - action: auto-login-action
          request: pre-os-command
          timeout:
            minutes: 2

  - test:
      timeout:
        minutes: 25
      definitions:
        - from: inline
          repository:
            metadata:
              format: Lava-Test Test Definition 1.0
              name: prep-tests
              description: Device preparation
            run:
              steps:
                - df
                - cat /sys/class/thermal/thermal_zone0/policy || true
                - echo "power_allocator" > /sys/class/thermal/thermal_zone0/policy || true
                - cat /sys/class/thermal/thermal_zone0/policy || true
                - cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies  | awk '{ print $(NF-1) }'  > /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
                - cat /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq || true
          name: prep-inline
          path: inline/prep.yaml
        - from: git
          repository: https://github.com/Linaro/test-definitions.git
          path: automated/linux/gpiod/gpiod.yaml
          name: libgpiod
