Skip to content
Snippets Groups Projects
Commit 50e8c82a authored by Jason Hiser's avatar Jason Hiser :tractor:
Browse files

Update fix-calls to fix-all for go programs. Add go testing

parent 432c3283
No related branches found
No related tags found
1 merge request!38Go support
......@@ -92,6 +92,7 @@ test-bins-arm64:
- ./cicd_testing/eh-tests.sh
- ./cicd_testing/builtin-xforms.sh
- ./cicd_testing/elfdep.sh
- ./cicd_testing/go_tests.sh
......
#!/bin/bash
set -e
set -x
cd /tmp/peasoup_test
export IDAROOT=$CICD_MODULE_WORK_DIR/idapro71
export IDASDK=$CICD_MODULE_WORK_DIR/idapro71_sdk
source set_env_vars
cd $PEASOUP_HOME/tests/go_test/
./testit.sh
......@@ -960,6 +960,16 @@ class FixCalls_t : public TransformStep_t
DatabaseID_t variant_id=BaseObj_t::NOT_IN_DATABASE;
public:
FixCalls_t()
{
const auto exe_reader = new EXEIO::exeio;
assert(exe_reader);
exe_reader->load((char*)"a.ncexe");
const auto has_pclntab = exe_reader->sections[".gopclntab"] != NULL;
if(has_pclntab)
fix_all=true;
}
int parseArgs(const vector<string> step_args)
{
......
hello
8q
panic
*.zipr
peasoup_exe*
package main
import (
"fmt"
"math"
)
type Point struct {
x int
y int
}
var results = make([][]Point, 0)
func main() {
Solve(8)
}
func Solve(n int) {
for col := 0; col < n; col++ {
start := Point{x: col, y: 0}
current := make([]Point, 0)
Recurse(start, current, n)
}
fmt.Print("Results:\n")
for _, result := range results {
fmt.Println(result)
}
fmt.Printf("There were %d results\n", len(results))
}
func Recurse(point Point, current []Point, n int) {
if CanPlace(point, current) {
current = append(current, point)
if len(current) == n {
c := make([]Point, n)
for i, point := range current {
c[i] = point
}
results = append(results, c)
} else {
for col := 0; col < n; col++ {
for row := point.y; row < n; row++ {
nextStart := Point{x: col, y: row}
Recurse(nextStart, current, n)
}
}
}
}
}
func CanPlace(target Point, board []Point) bool {
for _, point := range board {
if CanAttack(point, target) {
return false
}
}
return true
}
func CanAttack(a, b Point) bool {
//fmt.Print(a, b)
answer := a.x == b.x || a.y == b.y || math.Abs(float64(a.y-b.y)) == math.Abs(float64(a.x-b.x))
//fmt.Print(answer)
return answer
}
package main
import "fmt"
func main() {
f()
fmt.Println("Returned normally from f.")
}
func f() {
defer func() {
if r := recover(); r != nil {
fmt.Println("Recovered in f", r)
}
}()
fmt.Println("Calling g.")
g(0)
fmt.Println("Returned normally from g.")
}
func g(i int) {
if i > 3 {
fmt.Println("Panicking!")
panic(fmt.Sprintf("%v", i))
}
defer fmt.Println("Defer in g", i)
fmt.Println("Printing in g", i)
g(i + 1)
}
#!/bin/bash
testone()
{
local PUT=$1
local OPTS=$2
set -x
set -e
go build $PUT.go
$PSZ $PUT ./$PUT.zipr $OPTS
diff <(./$PUT 2>&1 ) <(./$PUT.zipr 2>&1 )
./$PUT > /dev/null 2>&1
local putRes=$?
./$PUT.zipr > /dev/null 2>&1
local putResZipr=$?
if [[ $putRes != $putResZipr ]];
then
echo failed!
exit 1
fi
rm -rf peasoup* $PUT.zipr $PUT.zipr
}
main()
{
for bench in panic hello 8q
do
for opts in "-c rida" ""
do
testone $bench "$opts"
done
done
exit 0
}
main "$@"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment