Add plans/ci.fmf and testcase Sanity/basic-smoke

This commit is contained in:
Edjunior Machado 2023-08-15 12:32:27 +02:00
commit 3f29806bc2
9 changed files with 330 additions and 0 deletions

1
.fmf/version Normal file
View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1,64 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /tools/delve/Sanity/basic-smoke
# Description: basic smoke test
# Author: Edjunior Machado <emachado@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2019 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/tools/delve/Sanity/basic-smoke
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE hello.go init.txt script.exp
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Edjunior Machado <emachado@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: basic smoke test" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 10m" >> $(METADATA)
@echo "RunFor: delve" >> $(METADATA)
@echo "Requires: delve golang expect" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA)
@echo "Architectures: x86_64 aarch64" >> $(METADATA)
rhts-lint $(METADATA)

View file

@ -0,0 +1,3 @@
PURPOSE of /tools/delve/Sanity/basic-smoke
Description: basic smoke test
Author: Edjunior Machado <emachado@redhat.com>

View file

@ -0,0 +1,13 @@
package main
import "fmt"
func hello_world() {
fmt.Println("Hello World")
}
func main() {
i := 10
hello_world()
i--
}

View file

@ -0,0 +1,9 @@
break main.main
continue
next
break hello_world
continue
next 4
locals
continue
exit

View file

@ -0,0 +1,34 @@
summary: basic smoke test
description: ''
enabled: true
link:
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=2098063
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=2078639
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=2076501
tag:
- CI-Tier-1
- NoRHEL4
- NoRHEL5
- TIPfail_Apps
- rhel8-gating
adjust:
- enabled: false
when: arch == aarch64, arm, armhfp, i386, ia64, ppc, ppc64, ppc64le, s390, s390x
continue: false
- enabled: false
when: distro == rhel-4, rhel-5
continue: false
contact: Edjunior Machado <emachado@redhat.com>
component:
- delve
- golang
test: ./runtest.sh
framework: beakerlib
recommend:
- delve
- golang
- expect
duration: 10m
extra-nitrate: TC#0605108
extra-summary: /tools/delve/Sanity/basic-smoke
extra-task: /tools/delve/Sanity/basic-smoke

120
Sanity/basic-smoke/runtest.sh Executable file
View file

@ -0,0 +1,120 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /tools/delve/Sanity/basic-smoke
# Description: basic smoke test
# Author: Edjunior Machado <emachado@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2019 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="$(rpm -qf $(which dlv))"
GO_PACKAGE="$(rpm -qf $(which go))"
rlJournalStart
rlPhaseStartSetup
if ! rlCheckRpm $PACKAGE; then
if rlIsRHEL && [ "$(arch)" != "x86_64" ]; then
rlLogInfo "RHEL delve currently is only supported on x86_64"
skip_test=1
else
rlRun go_version=$(go version | sed -e 's/go version go\(.*\) .*/\1/')
if rlTestVersion $go_version '<' 1.13; then
rlLogInfo "delve is not supported before go1.13"
skip_test=1
else
rlDie "delve is missing. Aborting testcase..."
fi
fi
else
rlAssertRpm $GO_PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "cp hello.go init.txt script.exp $TmpDir"
rlRun "pushd $TmpDir"
fi
rlPhaseEnd
if [ ! $skip_test ]; then
rlPhaseStartTest
rlRun "set -o pipefail"
rlRun -l "dlv" 0
rlRun -l "dlv version |& tee version.out" 0
rlAssertGrep "^Delve Debugger$" version.out
rlPhaseEnd
rlPhaseStartTest "Init file test"
rlRun "cat hello.go"
rlRun "go mod init main"
rlRun "cat init.txt"
rlRun "delve_version=$(dlv version | awk '/Version:/{ print $2}')"
# --allow-non-terminal-interactive=true is needed on delve 1.6.0 (rhel-8.5)
if rlTestVersion $delve_version '>=' 1.6; then
rlRun "DELVE_INIT_ARGS='--allow-non-terminal-interactive=true'"
else
rlRun "DELVE_INIT_ARGS=''"
fi
# delve should exit with 0 now, since rhbz#1780554 was fixed
rlRun "dlv debug $DELVE_INIT_ARGS --init ./init.txt |& tee debug.out" 0
if grep 'Version of Delve is too old' debug.out; then
rlFail "'Delve is too old' warning message"
rlLogInfo "Rerunning with --check-go-version=false"
rlRun "DELVE_IGNORE_GO_VERSION='--check-go-version=false'"
rlRun "dlv debug $DELVE_INIT_ARGS $DELVE_IGNORE_GO_VERSION --init ./init.txt |& tee debug.out" 0
fi
rlAssertGrep "^Breakpoint 1 set at .* for main.main() ./hello.go:9$" debug.out
rlAssertGrep "^Hello World$" debug.out
rlAssertGrep "^i = 9$" debug.out
rlAssertGrep "Process .* has exited with status 0$" debug.out
rlAssertNotGrep "failed" debug.out
rlFileSubmit debug.out
rlPhaseEnd
rlPhaseStartTest "Prompt test"
rlRun "expect -- script.exp $DELVE_IGNORE_GO_VERSION |& tee expect.log"
rlAssertGrep "PASS: break main.main" expect.log
rlAssertGrep "PASS: continue" expect.log
rlAssertGrep "PASS: next" expect.log
rlAssertGrep "PASS: break hello_world" expect.log
rlAssertGrep "PASS: c" expect.log
rlAssertGrep "PASS: next 4" expect.log
rlAssertGrep "PASS: locals" expect.log
rlAssertGrep "PASS: c (exit)" expect.log
rlAssertGrep "PASS: exit" expect.log
rlFileSubmit expect.log
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
fi
rlJournalPrintText
rlJournalEnd

View file

@ -0,0 +1,81 @@
#!/usr/bin/expect -f
set param [lindex $argv 0];
spawn dlv debug "$param"
match_max 100000
expect -exact "Type 'help' for list of commands.\r
(dlv) "
send -- "break main.main\r"
expect "break main.main\r
Breakpoint 1 set at * for main.main() ./hello.go:9\r
(dlv) " {
puts "PASS: break main.main"
}
send -- "continue\r"
expect "continue\r
> main.main() ./hello.go:9 (hits goroutine(1):1 total:1) (PC: 0x*)\r
*
*=>* 9:*func*main() {\r
*
(dlv) " {
puts "PASS: continue"
}
send -- "next\r"
expect "next\r
> main.main() ./hello.go:10 (PC: 0x*)\r
*
*=>* 10:*i := *10*\r
*
(dlv) " {
puts "PASS: next"
}
send -- "break hello_world\r"
expect "break hello_world\r
Breakpoint 2 set at 0x* for main.hello_world() ./hello.go:5\r
(dlv) " {
puts "PASS: break hello_world"
}
send -- "c\r"
expect "c\r
> main.hello_world() ./hello.go:5 (hits goroutine(1):1 total:1) (PC: 0x*)\r
*
*=>* 5:*func* hello_world() {\r
*
(dlv) " {
puts "PASS: c"
}
send -- "next 4\r"
expect "next 4\r
Hello World\r
> main.main() ./hello.go:13 (PC: 0x*)\r
*
*=>* 13:*}\r
(dlv) " {
puts "PASS: next 4"
}
send -- "locals\r"
expect -exact "locals\r
i = 9\r
(dlv) " {
puts "PASS: locals"
}
send -- "c\r"
expect "c\r
Process * has exited with status 0\r
(dlv) " {
puts "PASS: c (exit)"
}
send -- "exit\r"
expect eof {
puts "PASS: exit"
}

5
plans/ci.fmf Normal file
View file

@ -0,0 +1,5 @@
summary: CI Gating Plan
discover:
how: fmf
execute:
how: tmt