Skip to content

Instantly share code, notes, and snippets.

@ainar-g
Created February 22, 2016 21:16
Show Gist options
  • Select an option

  • Save ainar-g/c43446f60b3dded12e62 to your computer and use it in GitHub Desktop.

Select an option

Save ainar-g/c43446f60b3dded12e62 to your computer and use it in GitHub Desktop.
stoke issue 847
#!/bin/bash
set -e
STOKE=${STOKE:-stoke}
GO=${GO:-go}
cat > popcnt.go <<EOF
package main
//go:noinline
func popcnt(x uint64) int {
var res uint64
for ; x > 0; x >>= 1 {
res += x & 1
}
return int(res)
}
func main() {
println("popcnt start")
var iter uint64 = 100000000
for i := uint64(0); i < iter; i++ {
_ = popcnt(i)
}
println("popcnt end")
}
EOF
echo "written popcnt.go"
$GO build -o a.out popcnt.go
echo "built popcnt"
$STOKE extract -i ./a.out -o bins
echo "extracted bins"
# Remove all files with spaces in names.
find bins -name '* *' -exec rm {} \;
echo "generating testcases"
$STOKE testcase --bin ./a.out --functions bins -o popcnt.tc --fxn main_popcnt --max_testcases 1024
# Never printed.
echo "testcases generated"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment