Skip to content

Commit

Permalink
remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anpep committed Nov 28, 2024
1 parent 605499d commit c8600fe
Showing 1 changed file with 0 additions and 122 deletions.
122 changes: 0 additions & 122 deletions internals/daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1494,128 +1494,6 @@ type rebootSuite struct{}

var _ = Suite(&rebootSuite{})

/*func (s *rebootSuite) TestSyscallPosRebootDelay(c *C) {
wait := make(chan struct{})
defer FakeSyscallSync(func() {})()
defer FakeSyscallReboot(func(cmd int) error {
if cmd == syscall.LINUX_REBOOT_CMD_RESTART {
close(wait)
}
return nil
})()
period := 25 * time.Millisecond
syscallModeReboot(period)
start := time.Now()
select {
case <-wait:
case <-time.After(10 * time.Second):
c.Fatal("syscall did not take place and we timed out")
}
elapsed := time.Now().Sub(start)
c.Assert(elapsed >= period, Equals, true)
}
func (s *rebootSuite) TestSyscallNegRebootDelay(c *C) {
wait := make(chan struct{})
defer FakeSyscallSync(func() {})()
defer FakeSyscallReboot(func(cmd int) error {
if cmd == syscall.LINUX_REBOOT_CMD_RESTART {
close(wait)
}
return nil
})()
// Negative periods will be zeroed, so do not fear the huge negative.
// We do supply a rather big value here because this test is
// effectively a race, but given the huge timeout, it is not going
// to be a problem (c).
period := 10 * time.Second
go func() {
// We need a different thread for the unbuffered wait.
syscallModeReboot(-period)
}()
start := time.Now()
select {
case <-wait:
case <-time.After(10 * time.Second):
c.Fatal("syscall did not take place and we timed out")
}
elapsed := time.Now().Sub(start)
c.Assert(elapsed < period, Equals, true)
}
func (s *rebootSuite) TestSetSyscall(c *C) {
wait := make(chan struct{})
defer FakeSyscallSync(func() {})()
defer FakeSyscallReboot(func(cmd int) error {
if cmd == syscall.LINUX_REBOOT_CMD_RESTART {
close(wait)
}
return nil
})()
// We know the default is systemdReboot otherwise the unit tests
// above will fail. We need to check the switch works.
SetRebootMode(SyscallMode)
defer SetRebootMode(SystemdMode)
err := make(chan error)
go func() {
// We need a different thread for the unbuffered wait.
err <- rebootHandler(0)
}()
select {
case <-wait:
case <-time.After(10 * time.Second):
c.Fatal("syscall did not take place and we timed out")
}
c.Assert(<-err, IsNil)
}
type fakeLogger struct {
msg string
noticeCh chan int
}
func (f *fakeLogger) Notice(msg string) {
f.msg = msg
f.noticeCh <- 1
}
func (f *fakeLogger) Debug(msg string) {}
func (s *rebootSuite) TestSyscallRebootError(c *C) {
defer FakeSyscallSync(func() {})()
defer FakeSyscallReboot(func(cmd int) error {
return fmt.Errorf("-EPERM")
})()
// We know the default is systemdReboot otherwise the unit tests
// above will fail. We need to check the switch works.
SetRebootMode(SyscallMode)
defer SetRebootMode(SystemdMode)
complete := make(chan int)
l := fakeLogger{noticeCh: complete}
old := logger.SetLogger(&l)
defer logger.SetLogger(old)
err := make(chan error)
go func() {
// We need a different thread for the unbuffered wait.
err <- rebootHandler(0)
}()
select {
case <-complete:
case <-time.After(10 * time.Second):
c.Fatal("syscall did not take place and we timed out")
}
c.Assert(l.msg, Matches, "*-EPERM")
c.Assert(<-err, IsNil)
}*/

func (s *rebootSuite) TestCustomRebootHandler(c *C) {
wait := make(chan struct{})
SetRebootHandler(func(_ time.Duration) error {
Expand Down

0 comments on commit c8600fe

Please sign in to comment.