From 18ca48b13e1148466f465ac16c54ca408ed8b06d Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Wed, 3 Aug 2016 17:59:33 +0200 Subject: [PATCH] Add a test for the "user" applet --- tests/project.conf | 11 +++++++++-- tests/tests.sh | 1 + tests/user.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 tests/user.c diff --git a/tests/project.conf b/tests/project.conf index bb03bc2..fc89c0a 100644 --- a/tests/project.conf +++ b/tests/project.conf @@ -1,4 +1,4 @@ -targets=applets,applets2,tests.log +targets=applets,applets2,tests.log,user cppflags_force=-I ../include cflags_force=`pkg-config --cflags libDesktop` cflags=-W -Wall -g -O2 -pedantic -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector-all @@ -18,4 +18,11 @@ sources=applets2.c [tests.log] type=script script=./tests.sh -depends=$(OBJDIR)applets$(EXEEXT),$(OBJDIR)applets2$(EXEEXT),tests.sh +depends=$(OBJDIR)applets$(EXEEXT),$(OBJDIR)applets2$(EXEEXT),tests.sh,$(OBJDIR)user$(EXEEXT) + +[user] +type=binary +sources=user.c + +[user.c] +depends=../src/applets/user.c diff --git a/tests/tests.sh b/tests/tests.sh index 3d75f17..78f555c 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -99,6 +99,7 @@ target="$1" $DATE > "$target" FAILED= echo "Performing tests:" 1>&2 +_test "user" echo "Expected failures:" 1>&2 _fail "applets" [ -z "$DISPLAY" ] || _fail "applets2" diff --git a/tests/user.c b/tests/user.c new file mode 100644 index 0000000..71aab17 --- /dev/null +++ b/tests/user.c @@ -0,0 +1,47 @@ +/* $Id$ */ +/* Copyright (c) 2016 Pierre Pronchery */ +/* This file is part of DeforaOS Desktop Panel */ +/* 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, version 3 of the License. + * + * 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 . */ + + + +#include +#include "../src/applets/user.c" + +#define PROGNAME "user" + + +/* main */ +int main(void) +{ + int ret = 0; + struct passwd pw; + String * tooltip; + String const * expected = "Charlie Root\n" +"IT Department\n" +"+1-555-1234\n" +"+1-555-1337\n" +"\n" +"\n"; + + pw.pw_gecos = "Charlie Root,IT Department,+1-555-1234,+1-555-1337,,,"; + if((tooltip = _init_tooltip(&pw)) == NULL) + return 2; + if(string_compare(expected, tooltip) != 0) + { + printf("Obtained: %s\n", tooltip); + ret = 3; + } + string_delete(tooltip); + return ret; +}