Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
ac4dd680
Commit
ac4dd680
authored
Aug 03, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
35c7ae8b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
1 deletion
+58
-1
wcfs/testdata/zblk_test_gen.py
wcfs/testdata/zblk_test_gen.py
+1
-0
wcfs/zblk.go
wcfs/zblk.go
+20
-1
wcfs/zblk_test.go
wcfs/zblk_test.go
+36
-0
wcfs/ztestdata_zblk_test.go
wcfs/ztestdata_zblk_test.go
+1
-0
No files found.
wcfs/testdata/zblk_test_gen.py
View file @
ac4dd680
...
...
@@ -59,6 +59,7 @@ def main():
emit
(
"// Code generated by %s; DO NOT EDIT."
%
__file__
)
emit
(
"package main
\
n
"
)
emit
(
"const blksize = %s"
%
blksize
)
emit
(
"const z0_oid = %s"
%
u64
(
z0
.
_p_oid
))
emit
(
"const z1_oid = %s"
%
u64
(
z1
.
_p_oid
))
emit
(
"const zf_oid = %s"
%
u64
(
zf
.
_p_oid
))
...
...
wcfs/zblk.go
View file @
ac4dd680
...
...
@@ -22,10 +22,11 @@ package main
import
(
//
"context"
"context"
"fmt"
"reflect"
"lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb/btree"
pickle
"github.com/kisielk/og-rek"
...
...
@@ -59,6 +60,18 @@ func (zb *zBlk0State) PySetState(pystate interface{}) error {
return
nil
}
func
(
zb
*
ZBlk0
)
LoadBlkData
(
ctx
context
.
Context
)
([]
byte
,
error
)
{
// XXX err ctx
err
:=
zb
.
PActivate
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
defer
zb
.
PDeactivate
()
return
mem
.
Bytes
(
zb
.
blkdata
),
nil
}
// ---- ZBlk1 ---
// ZData mimics ZData from python.
...
...
@@ -107,6 +120,12 @@ func (zb *zBlk1State) PySetState(pystate interface{}) error {
return
nil
}
func
(
zb
*
ZBlk1
)
LoadBlkData
(
ctx
context
.
Context
)
([]
byte
,
error
)
{
// XXX empty .chunktab -> ø
panic
(
"TODO"
)
}
// ----------------------------------------
...
...
wcfs/zblk_test.go
View file @
ac4dd680
...
...
@@ -23,16 +23,20 @@ package main
import
(
"context"
"encoding/binary"
"testing"
"lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/neo/go/transaction"
"lab.nexedi.com/kirr/neo/go/zodb"
_
"lab.nexedi.com/kirr/neo/go/zodb/wks"
"github.com/stretchr/testify/require"
)
func
TestZBlk
(
t
*
testing
.
T
)
{
X
:=
exc
.
Raiseif
assert
:=
require
.
New
(
t
)
ctx
:=
context
.
Background
()
stor
,
err
:=
zodb
.
OpenStorage
(
ctx
,
"testdata/zblk.fs"
,
&
zodb
.
OpenOptions
{
ReadOnly
:
true
});
X
(
err
)
db
:=
zodb
.
NewDB
(
stor
)
...
...
@@ -63,7 +67,39 @@ func TestZBlk(t *testing.T) {
t
.
Fatalf
(
"zf: want ZBigFile; got %T"
,
xzf
)
}
xactivate
:=
func
(
obj
zodb
.
IPersistent
)
{
err
:=
obj
.
PActivate
(
ctx
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
// data that must be stored in ZBlk*
data
:=
make
([]
byte
,
blksize
)
for
i
:=
uint32
(
0
);
i
<
blksize
/
4
;
i
++
{
binary
.
BigEndian
.
PutUint32
(
data
[
i
*
4
:
],
i
)
}
z0Data
,
err
:=
z0
.
LoadBlkData
(
ctx
);
X
(
err
)
assert
.
Equal
(
z0Data
,
data
,
"ZBlk0 data wrong"
)
z1Data
,
err
:=
z1
.
LoadBlkData
(
ctx
);
X
(
err
)
assert
.
Equal
(
z1Data
,
data
,
"ZBlk0 data wrong"
)
// XXX
_
,
_
,
_
=
z0
,
z1
,
zf
_
=
xactivate
/*
xactivate(zf)
if zf.blksize != blksize {
t.Fatalf("zf: blksize=%d; want %d", zf.blksize, blksize)
}
// XXX zf.blktab.Get(0) -> z0
// XXX zf.blktab.Get(1) -> z1
*/
}
wcfs/ztestdata_zblk_test.go
View file @
ac4dd680
// Code generated by ./testdata/zblk_test_gen.py; DO NOT EDIT.
package
main
const
blksize
=
2097152
const
z0_oid
=
2
const
z1_oid
=
3
const
zf_oid
=
1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment