Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63d0d98a5c | ||
|
|
e739023529 | ||
|
|
a7a9c5cdae | ||
|
|
50822bd2fd | ||
|
|
00c79073f0 | ||
|
|
f5b36b37b6 | ||
|
|
c635f46439 | ||
|
|
16a359f944 | ||
|
|
9a972f4c25 | ||
|
|
9d06ac0157 | ||
|
|
cfac6a645d | ||
|
|
648c7c109f | ||
|
|
8946f93254 | ||
|
|
58e030de5d | ||
|
|
c2f8c210f8 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,7 @@
|
||||
build
|
||||
*.user
|
||||
version.h
|
||||
*.pyc
|
||||
*.todo
|
||||
packaging/make_ubuntu2.sh
|
||||
test_*.log
|
||||
|
||||
@@ -62,6 +62,17 @@ else()
|
||||
set(BACKTRACE_L_FLAGS "")
|
||||
endif()
|
||||
|
||||
check_c_source_compiles(
|
||||
"#define print(x) _Generic((x), default : print_unknown)(x) \n void print_unknown(){} \n int main () { print(0); }"
|
||||
HAS_GENERIC)
|
||||
|
||||
if(HAS_GENERIC)
|
||||
add_definitions(-DHAS_GENERIC)
|
||||
set(CSTD "c11")
|
||||
else()
|
||||
set(CSTD "c99")
|
||||
endif(HAS_GENERIC)
|
||||
|
||||
if( ENABLE_RSVG )
|
||||
pkg_check_modules( RSVG librsvg-2.0>=2.14.0 )
|
||||
endif( ENABLE_RSVG )
|
||||
@@ -116,11 +127,11 @@ include_directories( ${PROJECT_BINARY_DIR}
|
||||
|
||||
set( SOURCES src/config.c
|
||||
src/panel.c
|
||||
src/server.c
|
||||
src/util/server.c
|
||||
src/main.c
|
||||
src/init.c
|
||||
src/signals.c
|
||||
src/tracing.c
|
||||
src/util/signals.c
|
||||
src/util/tracing.c
|
||||
src/mouse_actions.c
|
||||
src/drag_and_drop.c
|
||||
src/clock/clock.c
|
||||
@@ -146,7 +157,9 @@ set( SOURCES src/config.c
|
||||
src/util/timer.c
|
||||
src/util/cache.c
|
||||
src/util/color.c
|
||||
src/util/print.c
|
||||
src/util/gradient.c
|
||||
src/util/test.c
|
||||
src/util/uevent.c
|
||||
src/util/window.c )
|
||||
|
||||
@@ -267,7 +280,7 @@ endif( RT_LIBRARY )
|
||||
target_link_libraries( tint2 m )
|
||||
|
||||
add_dependencies( tint2 version )
|
||||
set_target_properties( tint2 PROPERTIES COMPILE_FLAGS "-Wall -Wpointer-arith -fno-strict-aliasing -pthread -std=c99 ${ASAN_C_FLAGS} ${TRACING_C_FLAGS}" )
|
||||
set_target_properties( tint2 PROPERTIES COMPILE_FLAGS "-Wall -Wpointer-arith -fno-strict-aliasing -pthread -std=${CSTD} ${ASAN_C_FLAGS} ${TRACING_C_FLAGS}" )
|
||||
set_target_properties( tint2 PROPERTIES LINK_FLAGS "-pthread -fno-strict-aliasing ${ASAN_L_FLAGS} ${BACKTRACE_L_FLAGS} ${TRACING_L_FLAGS}" )
|
||||
|
||||
install( TARGETS tint2 DESTINATION bin )
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
2017-11-10 master
|
||||
2017-12-20 16.0
|
||||
- Fixes:
|
||||
- Taskbar: `taskbar_distribute_size = 1` now playes well with `task_align = center` and
|
||||
`task_align = right` (issue #688)
|
||||
- Enhancements:
|
||||
- Added Spanish translation (contributed by Vicmz)
|
||||
- Executor: updated tooltip documentation (issue #676)
|
||||
- Systray: warn on duplicate config option systray_name_filter (issue #652)
|
||||
- Changed standard from C99 to C11 to support generic printing for unit tests
|
||||
|
||||
2017-11-05 15.3
|
||||
- Fixes:
|
||||
@@ -971,3 +975,4 @@ released tint-0.2
|
||||
.
|
||||
.
|
||||
.
|
||||
.
|
||||
|
||||
12
README.md
12
README.md
@@ -1,5 +1,5 @@
|
||||
# Latest stable release: 15.3
|
||||
Changes: https://gitlab.com/o9000/tint2/blob/15.3/ChangeLog
|
||||
# Latest stable release: 16.0
|
||||
Changes: https://gitlab.com/o9000/tint2/blob/16.0/ChangeLog
|
||||
|
||||
Documentation: [doc/tint2.md](doc/tint2.md)
|
||||
|
||||
@@ -8,7 +8,7 @@ Compile it with (after you install the [dependencies](https://gitlab.com/o9000/t
|
||||
```
|
||||
git clone https://gitlab.com/o9000/tint2.git
|
||||
cd tint2
|
||||
git checkout 15.3
|
||||
git checkout 16.0
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
@@ -61,9 +61,9 @@ tint2 is a simple panel/taskbar made for modern X window managers. It was specif
|
||||
|
||||
# Known issues
|
||||
|
||||
* Graphic glitches on Intel graphics cards can be avoided by changing the acceleration method to UXA ([issue 595](https://gitlab.com/o9000/tint2/issues/595))
|
||||
* Window managers that do not follow exactly the EWMH specification might not interact well with tint2 (known issues for [awesome](https://gitlab.com/o9000/tint2/issues/385), [bspwm](https://gitlab.com/o9000/tint2/issues/524). [openbox-multihead](https://gitlab.com/o9000/tint2/issues/456))
|
||||
* Full transparency requires a compositor such as Compton (if not provided already by the window manager, as in Compiz/Unity, KDE or XFCE)
|
||||
* Graphical glitches on Intel graphics cards can be avoided by changing the acceleration method to UXA ([issue 595](https://gitlab.com/o9000/tint2/issues/595))
|
||||
* Window managers that do not follow exactly the EWMH specification might not interact well with tint2 ([issue 627](https://gitlab.com/o9000/tint2/issues/627)).
|
||||
* Full transparency requires a compositor such as Compton (if not provided already by the window manager, as in Compiz/Unity, KDE or XFCE).
|
||||
|
||||
# How can I help out?
|
||||
|
||||
|
||||
@@ -199,9 +199,9 @@ pre {
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="latest-stable-release-15-3"><span class="md2man-title">Latest</span> <span class="md2man-section">stable</span> <span class="md2man-date">release:</span> <span class="md2man-source">15.3</span><a name="latest-stable-release-15-3" href="#latest-stable-release-15-3" class="md2man-permalink" title="permalink"></a></h1><p>Changes: <a href="https://gitlab.com/o9000/tint2/blob/15.3/ChangeLog">https://gitlab.com/o9000/tint2/blob/15.3/ChangeLog</a></p><p>Documentation: <a href="manual.html">manual.html</a></p><p>Compile it with (after you install the <a href="https://gitlab.com/o9000/tint2/wikis/Install#dependencies">dependencies</a>):</p><pre class="highlight plaintext"><code>git clone https://gitlab.com/o9000/tint2.git
|
||||
<h1 id="latest-stable-release-16-0"><span class="md2man-title">Latest</span> <span class="md2man-section">stable</span> <span class="md2man-date">release:</span> <span class="md2man-source">16.0</span><a name="latest-stable-release-16-0" href="#latest-stable-release-16-0" class="md2man-permalink" title="permalink"></a></h1><p>Changes: <a href="https://gitlab.com/o9000/tint2/blob/16.0/ChangeLog">https://gitlab.com/o9000/tint2/blob/16.0/ChangeLog</a></p><p>Documentation: <a href="manual.html">manual.html</a></p><p>Compile it with (after you install the <a href="https://gitlab.com/o9000/tint2/wikis/Install#dependencies">dependencies</a>):</p><pre class="highlight plaintext"><code>git clone https://gitlab.com/o9000/tint2.git
|
||||
cd tint2
|
||||
git checkout 15.3
|
||||
git checkout 16.0
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
@@ -239,9 +239,9 @@ update-mime-database /usr/local/share/mime
|
||||
</ul>
|
||||
<h1 id="known-issues">Known issues<a name="known-issues" href="#known-issues" class="md2man-permalink" title="permalink"></a></h1>
|
||||
<ul>
|
||||
<li>Graphic glitches on Intel graphics cards can be avoided by changing the acceleration method to UXA (<a href="https://gitlab.com/o9000/tint2/issues/595">issue 595</a>)</li>
|
||||
<li>Window managers that do not follow exactly the EWMH specification might not interact well with tint2 (known issues for <a href="https://gitlab.com/o9000/tint2/issues/385">awesome</a>, <a href="https://gitlab.com/o9000/tint2/issues/524">bspwm</a>. <a href="https://gitlab.com/o9000/tint2/issues/456">openbox-multihead</a>)</li>
|
||||
<li>Full transparency requires a compositor such as Compton (if not provided already by the window manager, as in Compiz/Unity, KDE or XFCE)</li>
|
||||
<li>Graphical glitches on Intel graphics cards can be avoided by changing the acceleration method to UXA (<a href="https://gitlab.com/o9000/tint2/issues/595">issue 595</a>)</li>
|
||||
<li>Window managers that do not follow exactly the EWMH specification might not interact well with tint2 (<a href="https://gitlab.com/o9000/tint2/issues/627">issue 627</a>).</li>
|
||||
<li>Full transparency requires a compositor such as Compton (if not provided already by the window manager, as in Compiz/Unity, KDE or XFCE).</li>
|
||||
</ul>
|
||||
<h1 id="how-can-i-help-out">How can I help out?<a name="how-can-i-help-out" href="#how-can-i-help-out" class="md2man-permalink" title="permalink"></a></h1>
|
||||
<ul>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH TINT2 1 "2017\-11\-05" 15.3
|
||||
.TH TINT2 1 "2017\-12\-20" 16.0
|
||||
.SH NAME
|
||||
.PP
|
||||
tint2 \- lightweight panel/taskbar
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# TINT2 1 "2017-11-05" 15.3
|
||||
# TINT2 1 "2017-12-20" 16.0
|
||||
|
||||
## NAME
|
||||
tint2 - lightweight panel/taskbar
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "panel.h"
|
||||
#include "server.h"
|
||||
#include "signals.h"
|
||||
#include "test.h"
|
||||
#include "tooltip.h"
|
||||
#include "tracing.h"
|
||||
#include "uevent.h"
|
||||
@@ -48,6 +49,9 @@ void handle_cli_arguments(int argc, char **argv)
|
||||
} else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {
|
||||
fprintf(stdout, "tint2 version %s\n", VERSION_STRING);
|
||||
exit(0);
|
||||
} else if (strcmp(argv[i], "--test") == 0) {
|
||||
run_all_tests();
|
||||
exit(0);
|
||||
} else if (strcmp(argv[i], "-c") == 0) {
|
||||
if (i + 1 < argc) {
|
||||
i++;
|
||||
|
||||
41
src/panel.c
41
src/panel.c
@@ -494,9 +494,11 @@ gboolean resize_panel(void *obj)
|
||||
}
|
||||
}
|
||||
|
||||
// Distribute the remaining size between tasks
|
||||
// Distribute the remaining size between taskbars
|
||||
if (num_tasks > 0) {
|
||||
int task_size = total_size / num_tasks;
|
||||
if (taskbar_alignment != ALIGN_LEFT)
|
||||
task_size = MIN(task_size, panel_horizontal ? panel_config.g_task.maximum_width : panel_config.g_task.maximum_height);
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
if (!taskbar->area.on_screen)
|
||||
@@ -513,6 +515,43 @@ gboolean resize_panel(void *obj)
|
||||
taskbar->area.height += task_size;
|
||||
}
|
||||
}
|
||||
int slack = total_size - task_size * num_tasks;
|
||||
if (taskbar_alignment == ALIGN_RIGHT) {
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
if (!taskbar->area.on_screen)
|
||||
continue;
|
||||
if (panel_horizontal)
|
||||
taskbar->area.width += slack;
|
||||
else
|
||||
taskbar->area.height += slack;
|
||||
break;
|
||||
}
|
||||
} else if (taskbar_alignment == ALIGN_CENTER) {
|
||||
slack /= 2;
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
if (!taskbar->area.on_screen)
|
||||
continue;
|
||||
if (panel_horizontal)
|
||||
taskbar->area.width += slack;
|
||||
else
|
||||
taskbar->area.height += slack;
|
||||
taskbar->area.alignment = ALIGN_RIGHT;
|
||||
break;
|
||||
}
|
||||
for (int i = panel->num_desktops - 1; i >= 0; i--) {
|
||||
Taskbar *taskbar = &panel->taskbar[i];
|
||||
if (!taskbar->area.on_screen)
|
||||
continue;
|
||||
if (panel_horizontal)
|
||||
taskbar->area.width += slack;
|
||||
else
|
||||
taskbar->area.height += slack;
|
||||
taskbar->area.alignment = ALIGN_LEFT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No tasks => expand the first visible taskbar
|
||||
for (int i = 0; i < panel->num_desktops; i++) {
|
||||
|
||||
@@ -24,7 +24,7 @@ set(SOURCES ../util/common.c
|
||||
../util/cache.c
|
||||
../util/timer.c
|
||||
../config.c
|
||||
../server.c
|
||||
../util/server.c
|
||||
../launcher/apps-common.c
|
||||
../launcher/icon-theme-common.c
|
||||
md4.c
|
||||
|
||||
17
src/util/bool.h
Normal file
17
src/util/bool.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef BOOL_H
|
||||
#define BOOL_H
|
||||
|
||||
#ifndef bool
|
||||
#define bool int
|
||||
#define false 0
|
||||
#define true 1
|
||||
#endif
|
||||
|
||||
#define SUCCESS true
|
||||
#define FAILURE false
|
||||
|
||||
#ifndef Status
|
||||
typedef int Status;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
10
src/util/colors.h
Normal file
10
src/util/colors.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef COLORS_H
|
||||
#define COLORS_H
|
||||
|
||||
#define GREEN "\033[1;32m"
|
||||
#define YELLOW "\033[1;33m"
|
||||
#define RED "\033[1;31m"
|
||||
#define BLUE "\033[1;34m"
|
||||
#define RESET "\033[0m"
|
||||
|
||||
#endif
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include "common.h"
|
||||
#include "../server.h"
|
||||
#include "server.h"
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
@@ -12,12 +12,7 @@
|
||||
#include <Imlib2.h>
|
||||
#include <pango/pangocairo.h>
|
||||
#include "area.h"
|
||||
|
||||
#define GREEN "\033[1;32m"
|
||||
#define YELLOW "\033[1;33m"
|
||||
#define RED "\033[1;31m"
|
||||
#define BLUE "\033[1;34m"
|
||||
#define RESET "\033[0m"
|
||||
#include "colors.h"
|
||||
|
||||
#define MAX3(a, b, c) MAX(MAX(a, b), c)
|
||||
#define MIN3(a, b, c) MIN(MIN(a, b), c)
|
||||
|
||||
83
src/util/print.c
Normal file
83
src/util/print.c
Normal file
@@ -0,0 +1,83 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "print.h"
|
||||
|
||||
int print_uchar(unsigned char v)
|
||||
{
|
||||
return printf("%u", v);
|
||||
}
|
||||
|
||||
int print_char(char v)
|
||||
{
|
||||
return printf("%c", v);
|
||||
}
|
||||
|
||||
int print_short(short v)
|
||||
{
|
||||
return printf("%d", v);
|
||||
}
|
||||
|
||||
int print_ushort(unsigned short v)
|
||||
{
|
||||
return printf("%u", v);
|
||||
}
|
||||
|
||||
int print_int(int v)
|
||||
{
|
||||
return printf("%d", v);
|
||||
}
|
||||
|
||||
int print_uint(unsigned v)
|
||||
{
|
||||
return printf("%u", v);
|
||||
}
|
||||
|
||||
int print_long(long v)
|
||||
{
|
||||
return printf("%ld", v);
|
||||
}
|
||||
|
||||
int print_ulong(unsigned long v)
|
||||
{
|
||||
return printf("%lu", v);
|
||||
}
|
||||
|
||||
int print_long_long(long long v)
|
||||
{
|
||||
return printf("%lld", v);
|
||||
}
|
||||
|
||||
int print_ulong_long(unsigned long long v)
|
||||
{
|
||||
return printf("%llu", v);
|
||||
}
|
||||
|
||||
int print_float(float v)
|
||||
{
|
||||
return printf("%f", (double)v);
|
||||
}
|
||||
|
||||
int print_double(double v)
|
||||
{
|
||||
return printf("%f", v);
|
||||
}
|
||||
|
||||
int print_long_double(long double v)
|
||||
{
|
||||
return printf("%Lf", v);
|
||||
}
|
||||
|
||||
int print_string(char *s)
|
||||
{
|
||||
return printf("%s", s);
|
||||
}
|
||||
|
||||
int print_pointer(void *v)
|
||||
{
|
||||
return printf("%p", v);
|
||||
}
|
||||
|
||||
int print_unknown()
|
||||
{
|
||||
return printf("(variable of unknown type)");
|
||||
}
|
||||
61
src/util/print.h
Normal file
61
src/util/print.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef PRINT_H
|
||||
#define PRINT_H
|
||||
|
||||
#ifdef HAS_GENERIC
|
||||
|
||||
int print_uchar(unsigned char v);
|
||||
|
||||
int print_char(char v);
|
||||
|
||||
int print_short(short v);
|
||||
|
||||
int print_ushort(unsigned short v);
|
||||
|
||||
int print_int(int v);
|
||||
|
||||
int print_uint(unsigned v);
|
||||
|
||||
int print_long(long v);
|
||||
|
||||
int print_ulong(unsigned long v);
|
||||
|
||||
int print_long_long(long long v);
|
||||
|
||||
int print_ulong_long(unsigned long long v);
|
||||
|
||||
int print_float(float v);
|
||||
|
||||
int print_double(double v);
|
||||
|
||||
int print_long_double(long double v);
|
||||
|
||||
int print_string(char *s);
|
||||
|
||||
int print_pointer(void *v);
|
||||
|
||||
int print_unknown();
|
||||
|
||||
#define print(x) \
|
||||
_Generic((x), \
|
||||
unsigned char: print_uchar, \
|
||||
char: print_char, \
|
||||
short int: print_short, \
|
||||
unsigned short int: print_ushort, \
|
||||
int: print_int, \
|
||||
unsigned int: print_uint, \
|
||||
long int: print_long, \
|
||||
unsigned long int: print_ulong, \
|
||||
long long int: print_long_long, \
|
||||
unsigned long long int: print_ulong_long, \
|
||||
float: print_float, \
|
||||
double: print_double, \
|
||||
long double: print_long_double, \
|
||||
char *: print_string, \
|
||||
void *: print_pointer, \
|
||||
default : print_unknown)(x)
|
||||
|
||||
#else
|
||||
#define print(...) printf("Omitted, the compiler does not support C11 generics.\n")
|
||||
#endif
|
||||
|
||||
#endif
|
||||
159
src/util/test.c
Normal file
159
src/util/test.c
Normal file
@@ -0,0 +1,159 @@
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "colors.h"
|
||||
#include "signals.h"
|
||||
#include "test.h"
|
||||
|
||||
typedef struct TestListItem {
|
||||
Test *test;
|
||||
const char *name;
|
||||
} TestListItem;
|
||||
|
||||
static GList *all_tests = NULL;
|
||||
|
||||
void register_test_(Test *test, const char *name)
|
||||
{
|
||||
TestListItem *item = (TestListItem *)calloc(sizeof(TestListItem), 1);
|
||||
item->test = test;
|
||||
item->name = name;
|
||||
all_tests = g_list_append(all_tests, item);
|
||||
}
|
||||
|
||||
static char *test_log_name_from_test_name(const char *test_name)
|
||||
{
|
||||
char *output_name = g_strdup_printf("test_%s.log", test_name);
|
||||
char *result = strdup(output_name);
|
||||
g_free(output_name);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void redirect_test_output(const char *test_name)
|
||||
{
|
||||
char *output_name = test_log_name_from_test_name(test_name);
|
||||
int fd = open(output_name, O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
||||
if (fd == -1)
|
||||
goto err;
|
||||
if (dup2(fd, STDOUT_FILENO) == -1)
|
||||
goto err;
|
||||
if (dup2(fd, STDERR_FILENO) == -1)
|
||||
goto err;
|
||||
|
||||
close(fd);
|
||||
free(output_name);
|
||||
return;
|
||||
err:
|
||||
fprintf(stderr, "tint2: Could not redirect test output to file name: %s\n", output_name);
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
free(output_name);
|
||||
}
|
||||
|
||||
__attribute__((noreturn))
|
||||
static void run_test_child(TestListItem *item)
|
||||
{
|
||||
reset_signals();
|
||||
redirect_test_output(item->name);
|
||||
bool result = true;
|
||||
item->test(&result);
|
||||
exit(result ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static FILE *open_test_log(const char *test_name)
|
||||
{
|
||||
char *output_name = test_log_name_from_test_name(test_name);
|
||||
FILE *log = fopen(output_name, "a");
|
||||
free(output_name);
|
||||
return log;
|
||||
}
|
||||
|
||||
static Status run_test_parent(TestListItem *item, pid_t child)
|
||||
{
|
||||
FILE *log = open_test_log(item->name);
|
||||
if (child == -1) {
|
||||
fprintf(log, "\n" "Test failed, fork failed\n");
|
||||
fclose(log);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
int child_status;
|
||||
pid_t ret_pid = waitpid(child, &child_status, 0);
|
||||
if (ret_pid != child) {
|
||||
fprintf(log, "\n" "Test failed, waitpid failed\n");
|
||||
fclose(log);
|
||||
return FAILURE;
|
||||
}
|
||||
if (WIFEXITED(child_status)) {
|
||||
int exit_status = WEXITSTATUS(child_status);
|
||||
if (exit_status == EXIT_SUCCESS) {
|
||||
fprintf(log, "\n" "Test succeeded.\n");
|
||||
fclose(log);
|
||||
return SUCCESS;
|
||||
} else {
|
||||
fprintf(log, "\n" "Test failed, exit status: %d.\n", exit_status);
|
||||
fclose(log);
|
||||
return FAILURE;
|
||||
}
|
||||
} else if (WIFSIGNALED(child_status)) {
|
||||
int signal = WTERMSIG(child_status);
|
||||
fprintf(log, "\n" "Test failed, child killed by signal: %d.\n", signal);
|
||||
fclose(log);
|
||||
return FAILURE;
|
||||
} else {
|
||||
fprintf(log, "\n" "Test failed, waitpid failed.\n");
|
||||
fclose(log);
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
static Status run_test(TestListItem *item)
|
||||
{
|
||||
pid_t pid = fork();
|
||||
if (pid == 0)
|
||||
run_test_child(item);
|
||||
return run_test_parent(item, pid);
|
||||
}
|
||||
|
||||
void run_all_tests()
|
||||
{
|
||||
fprintf(stdout, BLUE "tint2: Running %d tests..." RESET "\n", g_list_length(all_tests));
|
||||
size_t count = 0, succeeded = 0, failed = 0;
|
||||
for (GList *l = all_tests; l; l = l->next) {
|
||||
TestListItem *item = (TestListItem *)l->data;
|
||||
Status status = run_test(item);
|
||||
count++;
|
||||
fprintf(stdout, BLUE "tint2: Test " YELLOW "%s" BLUE ": ", item->name);
|
||||
if (status == SUCCESS) {
|
||||
fprintf(stdout, GREEN "succeeded" RESET "\n");
|
||||
succeeded++;
|
||||
} else {
|
||||
fprintf(stdout, RED "failed" RESET "\n");
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
if (failed == 0)
|
||||
fprintf(stdout, BLUE "tint2: " GREEN "all %lu tests succeeded." RESET "\n", count);
|
||||
else
|
||||
fprintf(stdout, BLUE "tint2: " RED "%lu" BLUE " out of %lu tests " RED "failed." RESET "\n", failed, count);
|
||||
}
|
||||
|
||||
TEST(dummy) {
|
||||
int x = 2;
|
||||
int y = 2;
|
||||
ASSERT_EQUAL(x, y);
|
||||
}
|
||||
|
||||
TEST(dummyBad) {
|
||||
int x = 2;
|
||||
int y = 3;
|
||||
ASSERT_EQUAL(x, y);
|
||||
}
|
||||
72
src/util/test.h
Normal file
72
src/util/test.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef TEST_H
|
||||
#define TEST_H
|
||||
|
||||
#include "bool.h"
|
||||
#include "print.h"
|
||||
|
||||
typedef void Test(Status *test_result_);
|
||||
|
||||
void register_test_(Test *test, const char *name);
|
||||
|
||||
#define TEST(name) \
|
||||
void test_##name(Status *test_result_); \
|
||||
__attribute__((constructor)) void test_register_##name() \
|
||||
{ \
|
||||
register_test_(test_##name, #name); \
|
||||
} \
|
||||
void test_##name(Status *test_result_)
|
||||
|
||||
void run_all_tests();
|
||||
|
||||
#define FAIL_TEST_ \
|
||||
*test_result_ = FAILURE; \
|
||||
return;
|
||||
|
||||
#define ASSERT(value) \
|
||||
if (!(value)) { \
|
||||
FAIL_TEST_ \
|
||||
}
|
||||
|
||||
#define ASSERT_EQUAL(a, b) \
|
||||
if (!(a == b)) { \
|
||||
printf("Assertion failed: %s == %s: ", #a, #b); \
|
||||
print(a); \
|
||||
printf(" != "); \
|
||||
print(b); \
|
||||
FAIL_TEST_ \
|
||||
}
|
||||
|
||||
#define ASSERT_DIFFERENT(a, b) \
|
||||
if (a == b) { \
|
||||
printf("Assertion failed: %s != %s: ", #a, #b); \
|
||||
print(a); \
|
||||
printf(" == "); \
|
||||
print(b); \
|
||||
FAIL_TEST_ \
|
||||
}
|
||||
|
||||
|
||||
#define ASSERT_STR_EQUAL(a, b) \
|
||||
if (strcmp(a, b) != 0) { \
|
||||
printf("Assertion failed: %s == %s: ", #a, #b); \
|
||||
print(a); \
|
||||
printf(" != "); \
|
||||
print(b); \
|
||||
FAIL_TEST_ \
|
||||
}
|
||||
|
||||
#define ASSERT_STR_DIFFERENT(a, b) \
|
||||
if (strcmp(a, b) == 0) { \
|
||||
printf("Assertion failed: %s != %s: ", #a, #b); \
|
||||
print(a); \
|
||||
printf(" == "); \
|
||||
print(b); \
|
||||
FAIL_TEST_ \
|
||||
}
|
||||
|
||||
#define ASSERT_TRUE(value) ASSERT_EQUAL(value, 1)
|
||||
#define ASSERT_FALSE(value) ASSERT_EQUAL(value, 0)
|
||||
#define ASSERT_NULL(value) ASSERT_EQUAL(value, NULL)
|
||||
#define ASSERT_NON_NULL(value) ASSERT_DIFFERENT(value, NULL)
|
||||
|
||||
#endif
|
||||
@@ -285,6 +285,29 @@ def compile_and_report(src_dir, use_asan):
|
||||
print("Status: Succeeded in %.1f seconds" % (duration,), ok)
|
||||
|
||||
|
||||
def compile_remotely_and_report(host):
|
||||
print_err("Compiling on {0}...".format(host))
|
||||
print("# Compilation on {0}".format(host))
|
||||
start = time.time()
|
||||
c = run("ssh worker@{0} 'cd tint2 && git pull && mkdir -p build && rm -rf build && mkdir -p build && cd build && cmake .. && make && ./tint2 --version'".format(host), True)
|
||||
out, _ = c.communicate()
|
||||
duration = time.time() - start
|
||||
if c.returncode != 0:
|
||||
print("Status: Failed!", error)
|
||||
print("Output:")
|
||||
print("```\n" + out.strip() + "\n```")
|
||||
if "warning:" in out:
|
||||
print("Status: Succeeded with warnings!", warning)
|
||||
print("Warnings:")
|
||||
print("```", end="")
|
||||
for line in out.split("\n"):
|
||||
if "warning:" in line:
|
||||
print(line, end="")
|
||||
print("```", end="")
|
||||
else:
|
||||
print("Status: Succeeded in %.1f seconds" % (duration,), ok)
|
||||
|
||||
|
||||
def run_test(config, index, use_asan):
|
||||
print_err("Running test", index, "for config", config)
|
||||
print("# Test", index, "(ASAN on)" if use_asan else "")
|
||||
@@ -350,6 +373,8 @@ def main():
|
||||
show_timestamp()
|
||||
show_git_info(args.src_dir)
|
||||
show_system_info()
|
||||
compile_remotely_and_report("freebsd")
|
||||
compile_remotely_and_report("openbsd")
|
||||
for use_asan in [True, False]:
|
||||
compile_and_report(args.src_dir, use_asan)
|
||||
run_tests(use_asan)
|
||||
|
||||
@@ -6,3 +6,4 @@
|
||||
#define GETTEXT_PACKAGE
|
||||
#define HAVE_TRACING
|
||||
#define ENABLE_EXECINFO
|
||||
#define SN_API_NOT_YET_FROZEN
|
||||
|
||||
12
tint2.files
12
tint2.files
@@ -237,3 +237,15 @@ src/signals.c
|
||||
src/signals.h
|
||||
src/tracing.c
|
||||
src/tracing.h
|
||||
src/util/test.c
|
||||
src/util/test.h
|
||||
src/util/bool.h
|
||||
src/util/colors.h
|
||||
src/util/print.c
|
||||
src/util/print.h
|
||||
src/util/test.c
|
||||
src/util/test.h
|
||||
src/util/tracing.h
|
||||
src/util/tracing.c
|
||||
src/util/signals.h
|
||||
src/util/signals.c
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
.
|
||||
./build
|
||||
./src
|
||||
./src/battery
|
||||
./src/clock
|
||||
./src/execplugin
|
||||
./src/launcher
|
||||
./src/sysmon
|
||||
./src/systray
|
||||
./src/taskbar
|
||||
./src/tint2conf
|
||||
./src/launcher
|
||||
./src/tooltip
|
||||
./src/util
|
||||
/usr/include
|
||||
/usr/include/gtk-2.0
|
||||
/usr/include/glib-2.0
|
||||
/usr/include/gdk-pixbuf-2.0
|
||||
/usr/include/cairo
|
||||
./src/execplugin
|
||||
./src/button
|
||||
./src/freespace
|
||||
./src/separator
|
||||
/usr/include/pango-1.0
|
||||
/usr/include/cairo
|
||||
/usr/include/glib-2.0
|
||||
/usr/lib/x86_64-linux-gnu/glib-2.0/include
|
||||
/usr/include/pixman-1
|
||||
/usr/include/freetype2
|
||||
/usr/include/libpng12
|
||||
/usr/include/librsvg-2.0
|
||||
/usr/include/gdk-pixbuf-2.0
|
||||
/usr/include/startup-notification-1.0
|
||||
/usr/include
|
||||
po
|
||||
src/tint2conf/po
|
||||
src/freespace
|
||||
|
||||
Reference in New Issue
Block a user