Imported an initial test program
This commit is contained in:
parent
72e75e488b
commit
1713287ed8
5
Makefile
5
Makefile
|
@ -1,6 +1,6 @@
|
||||||
PACKAGE = Panel
|
PACKAGE = Panel
|
||||||
VERSION = 0.2.18
|
VERSION = 0.2.18
|
||||||
SUBDIRS = data doc include po src tools
|
SUBDIRS = data doc include po src tests tools
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
LN = ln -f
|
LN = ln -f
|
||||||
TAR = tar -czvf
|
TAR = tar -czvf
|
||||||
|
@ -115,6 +115,9 @@ dist:
|
||||||
$(PACKAGE)-$(VERSION)/src/applets/Makefile \
|
$(PACKAGE)-$(VERSION)/src/applets/Makefile \
|
||||||
$(PACKAGE)-$(VERSION)/src/applets/tasks.atoms \
|
$(PACKAGE)-$(VERSION)/src/applets/tasks.atoms \
|
||||||
$(PACKAGE)-$(VERSION)/src/applets/project.conf \
|
$(PACKAGE)-$(VERSION)/src/applets/project.conf \
|
||||||
|
$(PACKAGE)-$(VERSION)/tests/applets.c \
|
||||||
|
$(PACKAGE)-$(VERSION)/tests/Makefile \
|
||||||
|
$(PACKAGE)-$(VERSION)/tests/project.conf \
|
||||||
$(PACKAGE)-$(VERSION)/tools/embed.c \
|
$(PACKAGE)-$(VERSION)/tools/embed.c \
|
||||||
$(PACKAGE)-$(VERSION)/tools/message.c \
|
$(PACKAGE)-$(VERSION)/tools/message.c \
|
||||||
$(PACKAGE)-$(VERSION)/tools/notify.c \
|
$(PACKAGE)-$(VERSION)/tools/notify.c \
|
||||||
|
|
|
@ -2,5 +2,5 @@ package=Panel
|
||||||
version=0.2.18
|
version=0.2.18
|
||||||
config=h,sh
|
config=h,sh
|
||||||
|
|
||||||
subdirs=data,doc,include,po,src,tools
|
subdirs=data,doc,include,po,src,tests,tools
|
||||||
dist=COPYING,Makefile,config.h,config.sh
|
dist=COPYING,Makefile,config.h,config.sh
|
||||||
|
|
40
tests/Makefile
Normal file
40
tests/Makefile
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
TARGETS = applets
|
||||||
|
PREFIX = /usr/local
|
||||||
|
DESTDIR =
|
||||||
|
BINDIR = $(PREFIX)/bin
|
||||||
|
SBINDIR = $(PREFIX)/sbin
|
||||||
|
CC = cc
|
||||||
|
CPPFLAGSF= -I ../include
|
||||||
|
CPPFLAGS=
|
||||||
|
CFLAGSF = -W `pkg-config --cflags libDesktop`
|
||||||
|
CFLAGS = -Wall -g -O2
|
||||||
|
LDFLAGSF= -W `pkg-config --libs libDesktop`
|
||||||
|
RM = rm -f
|
||||||
|
LN = ln -f
|
||||||
|
MKDIR = mkdir -m 0755 -p
|
||||||
|
INSTALL = install
|
||||||
|
|
||||||
|
|
||||||
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
applets_OBJS = applets.o
|
||||||
|
applets_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||||
|
applets_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||||
|
|
||||||
|
applets: $(applets_OBJS)
|
||||||
|
$(CC) -o applets $(applets_OBJS) $(applets_LDFLAGS)
|
||||||
|
|
||||||
|
applets.o: applets.c
|
||||||
|
$(CC) $(applets_CFLAGS) -c applets.c
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) -- $(applets_OBJS)
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
$(RM) -- $(TARGETS)
|
||||||
|
|
||||||
|
install: $(TARGETS)
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
|
||||||
|
.PHONY: all clean distclean install uninstall
|
106
tests/applets.c
Normal file
106
tests/applets.c
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Copyright (c) 2013 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 <dirent.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include "Panel.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* private */
|
||||||
|
/* prototypes */
|
||||||
|
static int _applets(void);
|
||||||
|
|
||||||
|
static int _dlerror(char const * message, int ret);
|
||||||
|
static int _error(char const * message, int ret);
|
||||||
|
|
||||||
|
|
||||||
|
/* functions */
|
||||||
|
/* applets */
|
||||||
|
static int _applets(void)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
const char path[] = "../src/applets";
|
||||||
|
#ifdef __APPLE__
|
||||||
|
const char ext[] = ".dylib";
|
||||||
|
#else
|
||||||
|
const char ext[] = ".so";
|
||||||
|
#endif
|
||||||
|
DIR * dir;
|
||||||
|
struct dirent * de;
|
||||||
|
size_t len;
|
||||||
|
char * s;
|
||||||
|
void * p;
|
||||||
|
PanelAppletDefinition * pad;
|
||||||
|
|
||||||
|
if((dir = opendir(path)) == NULL)
|
||||||
|
return -_error("../src/applets", 1);
|
||||||
|
while((de = readdir(dir)) != NULL)
|
||||||
|
{
|
||||||
|
if((len = strlen(de->d_name)) < sizeof(ext))
|
||||||
|
continue;
|
||||||
|
if(strcmp(&de->d_name[len - sizeof(ext) + 1], ext) != 0)
|
||||||
|
continue;
|
||||||
|
if((s = malloc(sizeof(path) + len + 1)) == NULL)
|
||||||
|
{
|
||||||
|
ret += _error(de->d_name, 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
snprintf(s, sizeof(path) + len + 1, "%s/%s", path, de->d_name);
|
||||||
|
if((p = dlopen(s, RTLD_LAZY)) == NULL)
|
||||||
|
{
|
||||||
|
ret += _dlerror(s, 1);
|
||||||
|
free(s);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if((pad = dlsym(p, "applet")) == NULL)
|
||||||
|
ret += _dlerror(s, 1);
|
||||||
|
else
|
||||||
|
printf("%s: %s\n", de->d_name, pad->name);
|
||||||
|
free(s);
|
||||||
|
dlclose(p);
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* dlerror */
|
||||||
|
static int _dlerror(char const * message, int ret)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: %s\n", message, dlerror());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* error */
|
||||||
|
static int _error(char const * message, int ret)
|
||||||
|
{
|
||||||
|
perror(message);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* public */
|
||||||
|
/* functions */
|
||||||
|
/* main */
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
return (_applets() == 0) ? 0 : 2;
|
||||||
|
}
|
10
tests/project.conf
Normal file
10
tests/project.conf
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
targets=applets
|
||||||
|
cppflags_force=-I ../include
|
||||||
|
cflags_force=-W `pkg-config --cflags libDesktop`
|
||||||
|
cflags=-Wall -g -O2
|
||||||
|
ldflags_force=-W `pkg-config --libs libDesktop`
|
||||||
|
dist=Makefile
|
||||||
|
|
||||||
|
[applets]
|
||||||
|
type=binary
|
||||||
|
sources=applets.c
|
Loading…
Reference in New Issue
Block a user