Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- Makefile.am | 13 +++++++++++++ common/test-log.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ test-log | 3 +++ 3 files changed, 69 insertions(+) create mode 100644 common/test-log.cpp create mode 100755 test-log Unfortunately this test fails compiled with Fedora 25/26 (with default options) but the problem is a compiler error, see https://bugzilla.redhat.com/show_bug.cgi?id=1475237. I honestly prefer to have a test that fails instead of distributing a possible buggy executable. diff --git a/Makefile.am b/Makefile.am index 411bf0d..40db903 100644 --- a/Makefile.am +++ b/Makefile.am @@ -88,6 +88,19 @@ imagetest_SOURCES = \ TESTS = test-png EXTRA_DIST += test-png +check_PROGRAMS += test-log-win +TESTS += test-log +EXTRA_DIST += test-log + +test_log_win_LDFLAGS = $(AM_LDFLAGS) -Wl,--subsystem,console +test_log_win_SOURCES = \ + common/vdcommon.cpp \ + common/vdcommon.h \ + common/vdlog.cpp \ + common/vdlog.h \ + common/test-log.cpp \ + $(NULL) + deps.txt: $(AM_V_GEN)rpm -qa | grep $(host_os) | sort | unix2dos > $@ diff --git a/common/test-log.cpp b/common/test-log.cpp new file mode 100644 index 0000000..71b3de2 --- /dev/null +++ b/common/test-log.cpp @@ -0,0 +1,53 @@ +/* + Copyright (C) 2017 Red Hat, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#undef NDEBUG +#include <assert.h> +#include <iostream> +#include <fstream> +#include <string> +#include "vdlog.h" + +using namespace std; + +#define TEST_FILE "test.log" + +int main(int argc, char **argv) +{ + unlink(TEST_FILE); + TCHAR path[128]; + wcscpy(path, TEXT(TEST_FILE)); + VDLog *log = VDLog::get(path); + assert(log); + + log_version(); + vd_printf("Log something"); + log->printf("A number %d", 123456); + delete log; + + ifstream f(TEST_FILE); + string line; + getline(f, line); + assert(line.find("log_version") != string::npos); + getline(f, line); + assert(line.find("Log something") != string::npos); + getline(f, line); + assert(line.find("A number 123456") != string::npos); + f.close(); + + unlink(TEST_FILE); + return 0; +} diff --git a/test-log b/test-log new file mode 100755 index 0000000..4ba2efe --- /dev/null +++ b/test-log @@ -0,0 +1,3 @@ +#!/bin/bash + +exec wine test-log-win.exe -- 2.13.3 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel