[Spice-commits] 2 commits - server/tests
Frediano Ziglio
fziglio at kemper.freedesktop.org
Wed Mar 8 12:28:37 UTC 2017
server/tests/Makefile.am | 1
server/tests/pki/ca-cert.pem | 16 ++++++++
server/tests/pki/server-cert.pem | 18 +++++++++
server/tests/pki/server-key.pem | 15 +++++++
server/tests/test-leaks.c | 76 +++++++++++++++++++++++++++++++++++++--
5 files changed, 124 insertions(+), 2 deletions(-)
New commits:
commit 312c0aadf095d5ab6cb2df1efa888c42a234f975
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Mar 7 16:55:28 2017 +0000
test-leaks: Checks some leaks using TLS
Verify stuff are freed correctly (like TLS context).
The different PKI file required are generated with
base values (localhost and rsa 1024).
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
index db23177..3f61faa 100644
--- a/server/tests/Makefile.am
+++ b/server/tests/Makefile.am
@@ -1,6 +1,7 @@
NULL =
AM_CPPFLAGS = \
+ -DSPICE_TOP_SRCDIR=\"$(abs_top_srcdir)\"\
-I$(top_srcdir) \
-I$(top_srcdir)/server \
-I$(top_builddir)/server \
diff --git a/server/tests/pki/ca-cert.pem b/server/tests/pki/ca-cert.pem
new file mode 100644
index 0000000..a2068ce
--- /dev/null
+++ b/server/tests/pki/ca-cert.pem
@@ -0,0 +1,16 @@
+-----BEGIN CERTIFICATE-----
+MIICkTCCAfoCCQCRTWOpSfdW3jANBgkqhkiG9w0BAQsFADCBjDELMAkGA1UEBhMC
+VUsxCzAJBgNVBAgMAkNBMRIwEAYDVQQHDAlDYW1icmlkZ2UxEzARBgNVBAoMCkV4
+YW1wbGUgQ28xEDAOBgNVBAsMB3RlY2hvcHMxEzARBgNVBAMMClRlc3RpbmcgQ0Ex
+IDAeBgkqhkiG9w0BCQEWEWNlcnRzQGV4YW1wbGUuY29tMB4XDTE3MDMwNTE1NTE0
+NFoXDTQ0MDcyMDE1NTE0NFowgYwxCzAJBgNVBAYTAlVLMQswCQYDVQQIDAJDQTES
+MBAGA1UEBwwJQ2FtYnJpZGdlMRMwEQYDVQQKDApFeGFtcGxlIENvMRAwDgYDVQQL
+DAd0ZWNob3BzMRMwEQYDVQQDDApUZXN0aW5nIENBMSAwHgYJKoZIhvcNAQkBFhFj
+ZXJ0c0BleGFtcGxlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA8ZzC
+wYryCMwWSPJMrFCDn73+twpMfpW4J2DR+HTT3nBcjW5gIfZ6fUZWn0wovfeDqMiU
+1cKtJY45U14kwvZDuVTIZtpvqWAVX4t+KYN1MQuWuQsN7f9q6VEi0hyI9CiTi8PY
+tW2r0d/1SDdV4oKQBVwv15/zFJCETM38DPAxnYkCAwEAATANBgkqhkiG9w0BAQsF
+AAOBgQBw8BUg4l0EuZxy2F6z/wG7VSruHQupFexsJpIsr268wotpYnvAigXYCsh6
+PB042JHhBZs317GolUEExxWiLMjKcpggYYHX4WpA9nuN/QpK+1CrUmlILIrgTScY
+1Z7U7bRko3gBuF5dd7DneZQZGWBfpaqDbeufs1ZDTp5cIV8K5A==
+-----END CERTIFICATE-----
diff --git a/server/tests/pki/server-cert.pem b/server/tests/pki/server-cert.pem
new file mode 100644
index 0000000..cc90111
--- /dev/null
+++ b/server/tests/pki/server-cert.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC6DCCAlGgAwIBAgIJAKa/0Imqt34SMA0GCSqGSIb3DQEBCwUAMIGMMQswCQYD
+VQQGEwJVSzELMAkGA1UECAwCQ0ExEjAQBgNVBAcMCUNhbWJyaWRnZTETMBEGA1UE
+CgwKRXhhbXBsZSBDbzEQMA4GA1UECwwHdGVjaG9wczETMBEGA1UEAwwKVGVzdGlu
+ZyBDQTEgMB4GCSqGSIb3DQEJARYRY2VydHNAZXhhbXBsZS5jb20wHhcNMTcwMzA1
+MTU1MTQ0WhcNMTkxMTI5MTU1MTQ0WjCBizELMAkGA1UEBhMCVUsxCzAJBgNVBAgM
+AkNBMRIwEAYDVQQHDAlDYW1icmlkZ2UxETAPBgNVBAoMCEZyZWRpYW5vMRAwDgYD
+VQQLDAd0ZWNob3BzMRQwEgYDVQQDDAtUZXN0IFNlcnZlcjEgMB4GCSqGSIb3DQEJ
+ARYRY2VydHNAZXhhbXBsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
+AL7GOdOpqx26TSA/lQCOAcPGZ6mWhCtRUVaWXn+AKdmyNQ477ioSY2sSvTyYAodO
+hOHJo9UXQJ9Q526A4rGizCFZ4AdTX14j0Hf1V3Qx2yftLNKkjUol7ZI693FLltL0
+jiPStcB4YQbbtfywUIp9Qv9QP56Fym5DljaolGvBJ7wrAgMBAAGjUTBPMAwGA1Ud
+EwEB/wQCMAAwCwYDVR0PBAQDAgXgMDIGA1UdEQQrMCmCCWxvY2FsaG9zdIcEfwAA
+AYcQAAAAAAAAAAAAAAAAAAAAAYcEwKh/ATANBgkqhkiG9w0BAQsFAAOBgQA0Gtoc
+KKpnEsVxg89MlhFJw/H8DirfVTew2fXq65POBb42aku8yfBRwvhu+EkNO9qqDwGt
+NGBB/uJ2f4cpWX1T3rXLlTU9vX8+9sIHU7jAVz1Kkev/R2iXQBDM9lDMOde8fh7P
+x6vmcnKAGyQN4O1vOIl07K90dpZJ+QLL5SbhDA==
+-----END CERTIFICATE-----
diff --git a/server/tests/pki/server-key.pem b/server/tests/pki/server-key.pem
new file mode 100644
index 0000000..099e7e0
--- /dev/null
+++ b/server/tests/pki/server-key.pem
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXAIBAAKBgQC+xjnTqasduk0gP5UAjgHDxmeploQrUVFWll5/gCnZsjUOO+4q
+EmNrEr08mAKHToThyaPVF0CfUOdugOKxoswhWeAHU19eI9B39Vd0Mdsn7SzSpI1K
+Je2SOvdxS5bS9I4j0rXAeGEG27X8sFCKfUL/UD+ehcpuQ5Y2qJRrwSe8KwIDAQAB
+AoGAbC0nGTi6iS7dEQ48xYXAxmy411c8NvvzbW/ywcXA9Wqx3xJoqH6o1UxY9gUU
+WflSLF4Ugn6e7DgKI4T+BtBTgxMLgmPxn3pjCXLUlrh7F2Zw8YSVaEARc863kmK6
+BZElhmzZ4UzT5WCQhKMnxeCOGaoUuv6+0/epKc4vCCpU2bECQQDl1XtB9x0fwNMu
+o+PFAE71AfXjFLI8KSe1lp43zOXRzobOL9noYFyVgoaAoGguAAmz69w412LH9Hac
+aigGaYzlAkEA1H5Z3dL6hCkwNJ5A4VhVfmnFT0bSwrI+kc9QBgWw7wixNoF6HWSb
+FpYu3MIiVby1tZQiR0KwENWj1e5YACWjzwJBAJbkkNbfOZTGUR/246xMJop+7gNX
+bClJT9PNfjTeZihX8nNeQS9qTH6wQkQijCNfTP9+I4iCCE2E93Z7z6leFO0CQC3r
+3Fnu5Uq4Z/2HEbhhUaCPFR/ry1JeGN2D8uRKSJFvzHReCNjfTBDWhewZXDgxHwfN
+qpbB17Dbqptp9cSaXcsCQCxo3iKueTczYZN3bcDoxSwDLr3wSs9UJ0J7wpx+gW5y
+bsHXBmjDAPU47ivjjq1PqV2UtmmWep8UDImjuXiU5Wc=
+-----END RSA PRIVATE KEY-----
diff --git a/server/tests/test-leaks.c b/server/tests/test-leaks.c
index c9bc996..8ab8e15 100644
--- a/server/tests/test-leaks.c
+++ b/server/tests/test-leaks.c
@@ -22,6 +22,8 @@
#include "basic-event-loop.h"
#include "test-display-base.h"
+#define PKI_DIR SPICE_TOP_SRCDIR "/server/tests/pki/"
+
static void server_leaks(void)
{
int result;
@@ -33,6 +35,13 @@ static void server_leaks(void)
core = basic_event_loop_init();
g_assert_nonnull(core);
+ result = spice_server_set_tls(server, 5913,
+ PKI_DIR "ca-cert.pem",
+ PKI_DIR "server-cert.pem",
+ PKI_DIR "server-key.pem",
+ NULL, NULL, NULL);
+ g_assert_cmpint(result, ==, 0);
+
g_assert_cmpint(spice_server_init(server, core), ==, 0);
/* cause the allocation of spice name */
commit df48918dd0c4a3340158bd95c7125c73f53e2dc2
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu Nov 3 16:22:54 2016 +0000
test-leaks: Test that creating and destroying spicevmc does not leak
Add and remove some vmc device to check for leaking.
These combination assure that currently implemented type
of devices (webdav, usb and generic) are checked.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/tests/test-leaks.c b/server/tests/test-leaks.c
index e07e3c6..c9bc996 100644
--- a/server/tests/test-leaks.c
+++ b/server/tests/test-leaks.c
@@ -20,8 +20,9 @@
#include "test-glib-compat.h"
#include "basic-event-loop.h"
+#include "test-display-base.h"
-static void leaks(void)
+static void server_leaks(void)
{
int result;
SpiceCoreInterface *core;
@@ -45,11 +46,73 @@ static void leaks(void)
basic_event_loop_destroy();
}
+static int vmc_write(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
+ SPICE_GNUC_UNUSED const uint8_t *buf,
+ int len)
+{
+ return len;
+}
+
+static int vmc_read(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
+ SPICE_GNUC_UNUSED uint8_t *buf,
+ SPICE_GNUC_UNUSED int len)
+{
+ return 0;
+}
+
+static void vmc_state(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
+ SPICE_GNUC_UNUSED int connected)
+{
+}
+
+static SpiceCharDeviceInterface vmc_interface = {
+ .base.type = SPICE_INTERFACE_CHAR_DEVICE,
+ .base.description = "test spice virtual channel char device",
+ .base.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
+ .base.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
+ .state = vmc_state,
+ .write = vmc_write,
+ .read = vmc_read,
+};
+
+static SpiceCharDeviceInstance vmc_instance;
+
+static void vmc_leaks(void)
+{
+ SpiceCoreInterface *core = basic_event_loop_init();
+ Test *test = test_new(core);
+ int status;
+
+ vmc_instance.subtype = "usbredir";
+ vmc_instance.base.sif = &vmc_interface.base;
+ spice_server_add_interface(test->server, &vmc_instance.base);
+ status = spice_server_remove_interface(&vmc_instance.base);
+ g_assert_cmpint(status, ==, 0);
+
+ vmc_instance.subtype = "port";
+ vmc_instance.portname = "org.spice-space.webdav.0";
+ vmc_instance.base.sif = &vmc_interface.base;
+ spice_server_add_interface(test->server, &vmc_instance.base);
+ status = spice_server_remove_interface(&vmc_instance.base);
+ g_assert_cmpint(status, ==, 0);
+
+ vmc_instance.subtype = "port";
+ vmc_instance.portname = "default_port";
+ vmc_instance.base.sif = &vmc_interface.base;
+ spice_server_add_interface(test->server, &vmc_instance.base);
+ status = spice_server_remove_interface(&vmc_instance.base);
+ g_assert_cmpint(status, ==, 0);
+
+ test_destroy(test);
+ basic_event_loop_destroy();
+}
+
int main(int argc, char *argv[])
{
g_test_init(&argc, &argv, NULL);
- g_test_add_func("/server/server leaks", leaks);
+ g_test_add_func("/server/server leaks", server_leaks);
+ g_test_add_func("/server/vmc leaks", vmc_leaks);
return g_test_run();
}
More information about the Spice-commits
mailing list