[lxc-devel] [go-lxc/v2] Fix testsuite

stgraber on Github lxc-bot at linuxcontainers.org
Mon Apr 4 21:55:50 UTC 2016


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 538 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160404/dda867af/attachment.bin>
-------------- next part --------------
From 70d8633865dd21048f6d3770d09018b061a7fada Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 4 Apr 2016 17:54:38 -0400
Subject: [PATCH] Fix testsuite
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

 - Don't depend on a given terminal emulator
 - Don't depend on floats being exact match

Note that the testsuite shouldn't be run on btrfs as some extra failures
appear then.

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc_test.go | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lxc_test.go b/lxc_test.go
index 2a38228..825eb49 100644
--- a/lxc_test.go
+++ b/lxc_test.go
@@ -7,6 +7,7 @@
 package lxc
 
 import (
+	"fmt"
 	"math/rand"
 	"os"
 	"runtime"
@@ -864,7 +865,8 @@ func TestSetMemorySwapLimit(t *testing.T) {
 		t.Errorf(err.Error())
 	}
 
-	if newMemorySwapLimit != oldMemorySwapLimit/4 {
+	// Floats aren't exactly exact, check that we did get something smaller
+	if newMemorySwapLimit > oldMemorySwapLimit/3 {
 		t.Errorf("SetSwapLimit failed")
 	}
 }
@@ -957,7 +959,7 @@ func TestCommandWithEnvToKeep(t *testing.T) {
 	options.ClearEnv = true
 	options.EnvToKeep = []string{"TERM"}
 
-	args := []string{"/bin/sh", "-c", "test $TERM = 'xterm-256color'"}
+	args := []string{"/bin/sh", "-c", fmt.Sprintf("test $TERM = '%s'", os.Getenv("TERM"))}
 	ok, err := c.RunCommand(args, DefaultAttachOptions)
 	if err != nil {
 		t.Errorf(err.Error())


More information about the lxc-devel mailing list