Add a test for the "user" applet
This commit is contained in:
parent
44551ff63e
commit
18ca48b13e
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
47
tests/user.c
Normal file
47
tests/user.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2016 Pierre Pronchery <khorben@defora.org> */
|
||||
/* 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 <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user