Commit cf1f7c24 authored by Kirill Smelkov's avatar Kirill Smelkov

X tcpu: Don't depend on running tests with cwd = .../go/neo/t/

Previously when the code was trying to load testdata/ files with
different CWD it was failing with something like

	testdata/zlib/wczdata: no such file or directory.

Fix it by constructing testdata path relative to __file__ of
corresponding source.
parent d35a2fdf
......@@ -33,10 +33,12 @@ import (
"io/ioutil"
"log"
"os"
"path/filepath"
"strconv"
"testing"
"time"
"lab.nexedi.com/kirr/go123/my"
"lab.nexedi.com/kirr/neo/go/neo/internal/xzlib"
)
......@@ -106,8 +108,10 @@ func xreadfile(path string) []byte {
return data
}
var __dir__ = filepath.Dir(my.File())
func BenchmarkUnzlib(b *testing.B, zfile string) {
zdata := xreadfile(fmt.Sprintf("testdata/zlib/%s", zfile))
zdata := xreadfile(fmt.Sprintf("%s/testdata/zlib/%s", __dir__, zfile))
b.ResetTimer()
......
......@@ -28,6 +28,7 @@ import tzodb
import zlib
from time import time
from math import ceil, log10
from os.path import dirname
# fmtsize formats size in human readable form
_unitv = "BKMGT" # (2^10)^i represents by corresponding char suffix
......@@ -132,8 +133,11 @@ def readfile(path):
with open(path, 'r') as f:
return f.read()
__dir__ = dirname(__file__)
def bench_unzlib(b, zfile):
zdata = readfile('testdata/zlib/%s' % zfile)
zdata = readfile('%s/testdata/zlib/%s' % (__dir__, zfile))
b.reset_timer()
n = b.N
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment