Browse code

Move test cpu shares out of test start

Fixes #2107

Michael Crosby authored on 2013/12/05 09:31:09
Showing 1 changed files
... ...
@@ -330,6 +330,36 @@ func TestCommitRun(t *testing.T) {
330 330
 }
331 331
 
332 332
 func TestStart(t *testing.T) {
333
+	runtime := mkRuntime(t)
334
+	defer nuke(runtime)
335
+	container, _, _ := mkContainer(runtime, []string{"-i", "_", "/bin/cat"}, t)
336
+	defer runtime.Destroy(container)
337
+
338
+	cStdin, err := container.StdinPipe()
339
+	if err != nil {
340
+		t.Fatal(err)
341
+	}
342
+
343
+	if err := container.Start(); err != nil {
344
+		t.Fatal(err)
345
+	}
346
+
347
+	// Give some time to the process to start
348
+	container.WaitTimeout(500 * time.Millisecond)
349
+
350
+	if !container.State.IsRunning() {
351
+		t.Errorf("Container should be running")
352
+	}
353
+	if err := container.Start(); err == nil {
354
+		t.Fatalf("A running container should be able to be started")
355
+	}
356
+
357
+	// Try to avoid the timeout in destroy. Best effort, don't check error
358
+	cStdin.Close()
359
+	container.WaitTimeout(2 * time.Second)
360
+}
361
+
362
+func TestCpuShares(t *testing.T) {
333 363
 	_, err1 := os.Stat("/sys/fs/cgroup/cpuacct,cpu")
334 364
 	_, err2 := os.Stat("/sys/fs/cgroup/cpu,cpuacct")
335 365
 	if err1 == nil || err2 == nil {