- Pretty much completed set of examples and tests on 'pool' APIs implemented so far

This commit is contained in:
Faruk Kasumovic 2015-06-11 00:51:46 +02:00
parent c1288a9a2e
commit f7f90fe57f
2 changed files with 34 additions and 1 deletions

View File

@ -136,6 +136,13 @@ func PoolPropertyToName(p PoolProp) (name string) {
return
}
// Map POOL STATE to string.
func PoolStateToName(state PoolState) (name string) {
ps := C.pool_state_t(state)
name = C.GoString(C.zpool_pool_state_to_name(ps))
return
}
// Re-read ZFS pool properties and features, refresh Pool.Properties and
// Pool.Features map
func (pool *Pool) ReloadProperties() (err error) {

View File

@ -227,6 +227,17 @@ func zpoolTestPoolProp(t *testing.T) {
return
}
// this test pool should not be bootable
prop, err := pool.GetProperty(zfs.PoolPropBootfs)
if err != nil {
t.Error(err)
return
}
if prop.Value != "-" {
t.Errorf("Failed at bootable fs property evaluation")
return
}
// fetch all properties
if err = pool.ReloadProperties(); err != nil {
t.Error(err)
@ -253,10 +264,12 @@ func zpoolTestPoolStatusAndState(t *testing.T) {
return
}
if _, err = pool.State(); err != nil {
var pstate zfs.PoolState
if pstate, err = pool.State(); err != nil {
t.Error(err.Error())
return
}
println("POOL", TST_POOL_NAME, "state:", zfs.PoolStateToName(pstate))
println("PASS\n")
}
@ -412,3 +425,16 @@ func ExamplePool_ExportForce() {
panic(err)
}
}
func ExamplePool_State() {
p, err := zfs.PoolOpen("TESTPOOL")
if err != nil {
panic(err)
}
defer p.Close()
pstate, err := p.State()
if err != nil {
panic(err)
}
println("POOL TESTPOOL state:", zfs.PoolStateToName(pstate))
}