-SUBDIRS = libply libply-splash-core libply-splash-graphics . plugins client viewer tests
+SUBDIRS = libply libply-splash-core libply-splash-graphics . plugins client viewer
if ENABLE_UPSTART_MONITORING
SUBDIRS += upstart-bridge
endif
-SUBDIRS = . tests
-
INCLUDES = -I$(top_srcdir) \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/libply \
}
-#ifdef PLY_BOOT_CLIENT_ENABLE_TEST
-
-#include <stdio.h>
-
-#include "ply-event-loop.h"
-#include "ply-boot-client.h"
-
-static void
-on_pinged (ply_event_loop_t *loop)
-{
- printf ("PING!\n");
-}
-
-static void
-on_ping_failed (ply_event_loop_t *loop)
-{
- printf ("PING FAILED! %m\n");
- ply_event_loop_exit (loop, 1);
-}
-
-static void
-on_update (ply_event_loop_t *loop)
-{
- printf ("UPDATE!\n");
-}
-
-static void
-on_update_failed (ply_event_loop_t *loop)
-{
- printf ("UPDATE FAILED! %m\n");
- ply_event_loop_exit (loop, 1);
-}
-
-static void
-on_newroot (ply_event_loop_t *loop)
-{
- printf ("NEWROOT!\n");
-}
-
-static void
-on_system_initialized (ply_event_loop_t *loop)
-{
- printf ("SYSTEM INITIALIZED!\n");
-}
-
-static void
-on_system_initialized_failed (ply_event_loop_t *loop)
-{
- printf ("SYSTEM INITIALIZATION REQUEST FAILED!\n");
- ply_event_loop_exit (loop, 1);
-}
-
-static void
-on_quit (ply_event_loop_t *loop)
-{
- printf ("QUIT!\n");
- ply_event_loop_exit (loop, 0);
-}
-
-static void
-on_quit_failed (ply_event_loop_t *loop)
-{
- printf ("QUIT FAILED! %m\n");
- ply_event_loop_exit (loop, 2);
-}
-
-static void
-on_disconnect (ply_event_loop_t *loop)
-{
- printf ("DISCONNECT!\n");
- ply_event_loop_exit (loop, 1);
-}
-
-int
-main (int argc,
- char **argv)
-{
- ply_event_loop_t *loop;
- ply_boot_client_t *client;
- int exit_code;
-
- exit_code = 0;
-
- loop = ply_event_loop_new ();
-
- client = ply_boot_client_new ();
-
- if (!ply_boot_client_connect (client,
- (ply_boot_client_disconnect_handler_t) on_disconnect,
- loop))
- {
- perror ("could not start boot client");
- return errno;
- }
-
- ply_boot_client_attach_to_event_loop (client, loop);
- ply_boot_client_ping_daemon (client,
- (ply_boot_client_response_handler_t) on_pinged,
- (ply_boot_client_response_handler_t) on_ping_failed,
- loop);
-
- ply_boot_client_update_daemon (client,
- "loading",
- (ply_boot_client_response_handler_t) on_update,
- (ply_boot_client_response_handler_t) on_update_failed,
- loop);
-
- ply_boot_client_update_daemon (client,
- "loading more",
- (ply_boot_client_response_handler_t) on_update,
- (ply_boot_client_response_handler_t) on_update_failed,
- loop);
-
- ply_boot_client_tell_daemon_system_is_initialized (client,
- (ply_boot_client_response_handler_t)
- on_system_initialized,
- (ply_boot_client_response_handler_t)
- on_system_initialized_failed,
- loop);
-
- ply_boot_client_tell_daemon_to_quit (client,
- (ply_boot_client_response_handler_t) on_quit,
- (ply_boot_client_response_handler_t) on_quit_failed,
- loop);
-
- exit_code = ply_event_loop_run (loop);
-
- ply_boot_client_free (client);
-
- return exit_code;
-}
-
-#endif /* PLY_BOOT_CLIENT_ENABLE_TEST */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
+++ /dev/null
-INCLUDES = \
- -I$(top_srcdir) \
- -I$(srcdir)/.. \
- -I$(srcdir)/../.. \
- -I$(srcdir)
-TESTS =
-
-noinst_PROGRAMS = $(TESTS)
-
-MAINTAINERCLEANFILES = Makefile.in
+++ /dev/null
-TESTS += ply-boot-client-test
-
-ply_boot_client_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BOOT_CLIENT_ENABLE_TEST
-ply_boot_client_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_boot_client_test_SOURCES = \
- $(srcdir)/../ply-utils.h \
- $(srcdir)/../ply-utils.c \
- $(srcdir)/../ply-logger.h \
- $(srcdir)/../ply-logger.c \
- $(srcdir)/../ply-list.h \
- $(srcdir)/../ply-list.c \
- $(srcdir)/../ply-event-loop.h \
- $(srcdir)/../ply-event-loop.c \
- $(srcdir)/../ply-boot-client.h \
- $(srcdir)/../ply-boot-client.c
splash->plugin_interface->become_idle (splash->plugin, splash->idle_trigger);
}
-#ifdef PLY_BOOT_SPLASH_ENABLE_TEST
-
-#include <stdio.h>
-
-#include "ply-event-loop.h"
-#include "ply-boot-splash.h"
-
-typedef struct test_state test_state_t;
-struct test_state {
- ply_event_loop_t *loop;
- ply_boot_splash_t *splash;
- ply_buffer_t *buffer;
-};
-
-static void
-on_timeout (ply_boot_splash_t *splash)
-{
- ply_boot_splash_update_status (splash, "foo");
- ply_event_loop_watch_for_timeout (splash->loop,
- 5.0,
- (ply_event_loop_timeout_handler_t)
- on_timeout,
- splash);
-}
-
-static void
-on_quit (test_state_t *state)
-{
- ply_boot_splash_hide (state->splash);
- ply_event_loop_exit (state->loop, 0);
-}
-
-static void
-add_displays_to_splash_from_renderer (test_state_t *state,
- ply_renderer_t *renderer)
-{
- ply_list_t *heads;
- ply_list_node_t *node;
-
- heads = ply_renderer_get_heads (renderer);
-
- node = ply_list_get_first_node (heads);
- while (node != NULL)
- {
- ply_list_node_t *next_node;
- ply_renderer_head_t *head;
- ply_pixel_display_t *display;
-
- head = ply_list_node_get_data (node);
- next_node = ply_list_get_next_node (heads, node);
-
- display = ply_pixel_display_new (renderer, head);
-
- ply_boot_splash_add_pixel_display (state->splash, display);
-
- node = next_node;
- }
-}
-
-int
-main (int argc,
- char **argv)
-{
- int exit_code;
- test_state_t state;
- char *tty_name;
- const char *theme_path;
- ply_text_display_t *text_display;
- ply_renderer_t *renderer;
- ply_terminal_t *terminal;
- ply_keyboard_t *keyboard;
-
- exit_code = 0;
-
- state.loop = ply_event_loop_new ();
-
- if (argc > 1)
- theme_path = argv[1];
- else
- theme_path = PLYMOUTH_THEME_PATH "/fade-in/fade-in.plymouth";
-
- if (argc > 2)
- asprintf(&tty_name, "tty%s", argv[2]);
- else
- tty_name = strdup("tty0");
-
- terminal = ply_terminal_new (tty_name);
-
- if (!ply_terminal_open (terminal))
- {
- perror ("could not open tty");
- return errno;
- }
-
- renderer = ply_renderer_new (PLY_RENDERER_TYPE_AUTO, NULL, terminal);
- free(tty_name);
-
- if (!ply_renderer_open (renderer))
- {
- perror ("could not open renderer /dev/fb");
- ply_renderer_free (renderer);
- return errno;
- }
-
- keyboard = ply_keyboard_new_for_renderer (renderer);
- ply_keyboard_add_escape_handler (keyboard,
- (ply_keyboard_escape_handler_t) on_quit, &state);
-
- state.buffer = ply_buffer_new ();
- state.splash = ply_boot_splash_new (theme_path, PLYMOUTH_PLUGIN_PATH, state.buffer);
-
- if (!ply_boot_splash_load (state.splash))
- {
- perror ("could not load splash screen");
- return errno;
- }
-
- ply_boot_splash_set_keyboard (state.splash, keyboard);
- add_displays_to_splash_from_renderer (&state, renderer);
-
- text_display = ply_text_display_new (terminal);
- ply_boot_splash_add_text_display (state.splash, text_display);
-
- ply_boot_splash_attach_to_event_loop (state.splash, state.loop);
-
- if (!ply_boot_splash_show (state.splash, PLY_BOOT_SPLASH_MODE_BOOT_UP))
- {
- perror ("could not show splash screen");
- return errno;
- }
-
- ply_event_loop_watch_for_timeout (state.loop,
- 1.0,
- (ply_event_loop_timeout_handler_t)
- on_timeout,
- state.splash);
- exit_code = ply_event_loop_run (state.loop);
- ply_boot_splash_free (state.splash);
- ply_buffer_free (state.buffer);
-
- return exit_code;
-}
-
-#endif /* PLY_BOOT_SPLASH_ENABLE_TEST */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
-SUBDIRS = tests
INCLUDES = -I$(top_srcdir) \
-I$(srcdir) \
-DPLYMOUTH_TIME_DIRECTORY=\"$(localstatedir)/lib/plymouth/\"
return data;
}
-#ifdef PLY_ARRAY_ENABLE_TEST
-#include <stdio.h>
-
-int
-main (int argc,
- char **argv)
-{
- ply_array_t *array;
- int i;
- char **data;
-
- array = ply_array_new (PLY_ARRAY_ELEMENT_TYPE_POINTER);
-
- ply_array_add_pointer_element (array, "foo");
- ply_array_add_pointer_element (array, "bar");
- ply_array_add_pointer_element (array, "baz");
- ply_array_add_pointer_element (array, "qux");
-
- data = (char **) ply_array_get_pointer_elements (array);
- for (i = 0; data[i] != NULL; i++)
- {
- printf ("element '%d' has data '%s'\n", i, data[i]);
- i++;
- }
-
- ply_array_free (array);
- return 0;
-}
-
-#endif
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
return count;
}
-
-
-
-#ifdef PLY_BITARRAY_ENABLE_TEST
-#include <stdio.h>
-
-int
-main (int argc,
- char **argv)
-{
- ply_bitarray_t *bitarray;
- int i, i2;
- printf ("bitarray test start\n");
- bitarray = ply_bitarray_new (134);
-
- for (i=0; i<64; i++)
- {
- if (ply_bitarray_lookup (bitarray, i))
- printf ("1");
- else
- printf ("0");
- }
- printf ("\n");
-
- for (i=0; i<64; i++)
- if ((6654654654654654654ll >> i) & 1)
- ply_bitarray_set (bitarray, i);
-
- for (i=0; i<64; i++)
- {
- if (ply_bitarray_lookup (bitarray, i))
- printf ("1");
- else
- printf ("0");
- }
- printf ("\n");
-
- for (i = 63; i > 0; i--)
- {
- if ((6654654654654654654ll >> i) & 1)
- {
- ply_bitarray_clear (bitarray, i);
- for (i2 = 0; i2 < 64; i2++)
- {
- if (ply_bitarray_lookup (bitarray, i2))
- printf ("1");
- else
- printf ("0");
- }
- printf ("\n");
- }
- }
-
- ply_bitarray_free (bitarray);
-
- printf ("bitarray test end\n");
- return 0;
-}
-
-#endif
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
buffer->size = 0;
}
-#ifdef PLY_BUFFER_ENABLE_TEST
-int
-main (int argc,
- char **argv)
-{
- int exit_code;
- ply_buffer_t *buffer;
-
- exit_code = 0;
- buffer = ply_buffer_new ();
-
- ply_buffer_append (buffer, "yo yo yo\n");
- ply_buffer_free (buffer);
-
- return exit_code;
-}
-
-#endif /* PLY_BUFFER_ENABLE_TEST */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
return parsed_arguments;
}
-#ifdef PLY_COMMAND_PARSER_ENABLE_TEST
-
-#include <stdio.h>
-
-#include "ply-command-parser.h"
-#include "ply-event-loop.h"
-#include "ply-logger.h"
-
-static void
-on_ask_for_password (ply_command_parser_t *parser,
- const char *command)
-{
- char *prompt;
- char *program;
-
- prompt = NULL;
- program = NULL;
- ply_command_parser_get_command_options (parser, command, "prompt", &prompt, "command", &program, NULL);
-
- printf ("ask for password with prompt '%s' feed result to '%s'\n", prompt, program);
- free (prompt);
- free (program);
-}
-
-static void
-on_show_splash (ply_command_parser_t *parser,
- const char *command)
-{
- char *plugin_name;
-
- plugin_name = NULL;
- ply_command_parser_get_command_options (parser, command, "plugin-name", &plugin_name, NULL);
-
- printf ("show splash plugin '%s'\n", plugin_name);
- free (plugin_name);
-}
-
-int
-main (int argc,
- char **argv)
-{
- ply_event_loop_t *loop;
- ply_command_parser_t *parser;
- bool should_help;
-
- loop = ply_event_loop_new ();
- parser = ply_command_parser_new (argv[0], "Test Program");
-
- ply_command_parser_add_options (parser,
- "help", "This help message", PLY_COMMAND_OPTION_TYPE_FLAG,
- NULL);
-
- ply_command_parser_add_command (parser,
- "ask-for-password",
- "Ask user for password",
- (ply_command_handler_t)
- on_ask_for_password, parser,
- "command", "command to pipe result to", PLY_COMMAND_OPTION_TYPE_STRING,
- "prompt", "string to present to user", PLY_COMMAND_OPTION_TYPE_STRING,
- "output-result", "print result", PLY_COMMAND_OPTION_TYPE_BOOLEAN,
- NULL);
-
- ply_command_parser_add_command (parser,
- "show-splash",
- "Show splash to user",
- (ply_command_handler_t)
- on_show_splash, parser,
- "plugin-name", "name of the plugin to run", PLY_COMMAND_OPTION_TYPE_STRING,
- NULL);
-
- if (!ply_command_parser_parse_arguments (parser, loop, argv, argc))
- {
- ply_error ("couldn't parse arguments");
- return 1;
- }
-
-
- ply_command_parser_get_options (parser, "help", &should_help, NULL);
-
- if (should_help)
- {
- char *usage;
- usage = ply_command_parser_get_help_string (parser);
- printf ("%s\n", usage);
- free (usage);
- return 0;
- }
-
- ply_event_loop_run (loop);
-
- ply_command_parser_free (parser);
-
- return 0;
-}
-
-#endif
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
return loop->exit_code;
}
-#ifdef PLY_EVENT_LOOP_ENABLE_TEST
-
-static ply_event_loop_t *loop;
-
-static void
-alrm_signal_handler (void)
-{
- write (1, "times up!\n", sizeof ("times up!\n") - 1);
- ply_event_loop_exit (loop, 0);
-}
-
-static void
-usr1_signal_handler (void)
-{
- write (1, "got sigusr1\n", sizeof ("got sigusr1\n") - 1);
-}
-
-static void
-hangup_signal_handler (void)
-{
- write (1, "got hangup\n", sizeof ("got hangup\n") - 1);
-}
-
-static void
-terminate_signal_handler (void)
-{
- write (1, "got terminate\n", sizeof ("got terminate\n") - 1);
- ply_event_loop_exit (loop, 0);
-}
-
-static void
-line_received_handler (void)
-{
- char line[512] = { 0 };
- printf ("Received line: ");
- fflush (stdout);
-
- fgets (line, sizeof (line), stdin);
- printf ("%s", line);
-}
-
-static void
-on_timeout (ply_event_loop_t *loop)
-{
- printf ("timeout elapsed\n");
-}
-
-int
-main (int argc,
- char **argv)
-{
- int exit_code;
-
- loop = ply_event_loop_new ();
-
- ply_event_loop_watch_signal (loop, SIGHUP,
- (ply_event_handler_t) hangup_signal_handler,
- NULL);
- ply_event_loop_watch_signal (loop, SIGTERM,
- (ply_event_handler_t)
- terminate_signal_handler, NULL);
- ply_event_loop_watch_signal (loop, SIGUSR1,
- (ply_event_handler_t)
- usr1_signal_handler, NULL);
- ply_event_loop_watch_signal (loop, SIGALRM,
- (ply_event_handler_t)
- alrm_signal_handler, NULL);
-
- ply_event_loop_watch_for_timeout (loop, 2.0,
- (ply_event_loop_timeout_handler_t)
- on_timeout, loop);
- ply_event_loop_watch_fd (loop, 0, PLY_EVENT_LOOP_FD_STATUS_HAS_DATA,
- (ply_event_handler_t) line_received_handler,
- (ply_event_handler_t) line_received_handler,
- NULL);
-
- alarm (5);
- exit_code = ply_event_loop_run (loop);
-
- ply_event_loop_free (loop);
-
- return exit_code;
-}
-#endif /* PLY_EVENT_LOOP_ENABLE_TEST */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
{
unsigned int hash_index;
int step = 0;
-
-#ifdef PLY_HASHTABLE_ENABLE_TEST
- /* Make sure the counts are synchronised with bitmap */
- assert (ply_bitarray_count (hashtable->dirty_node_bitmap, hashtable->total_node_count) ==
- (int) hashtable->dirty_node_count);
- assert (ply_bitarray_count (hashtable->live_node_bitmap, hashtable->total_node_count) ==
- (int) hashtable->live_node_count);
-#endif /* PLY_HASHTABLE_ENABLE_TEST */
hash_index = hashtable->hash_func (key);
hash_index &= hashtable->total_node_count - 1;
return hashtable->live_node_count;
}
-#ifdef PLY_HASHTABLE_ENABLE_TEST
-#include <stdio.h>
-
-static void
-foreach_func (void *key,
- void *data,
- void *user_data)
-{
- printf ("foreach key:%s data:%s\n", (char*) key, (char*) data);
-}
-
-
-int
-main (int argc,
- char **argv)
-{
- ply_hashtable_t *hashtable;
- int i;
- const char* key[10] = {"k1", "k2", "k3", "k4", "k5", "k6", "k7", "k8", "k9", "k10"};
- const char* data[10] = {"d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10"};
- char* reply_key = NULL;
- char* reply_data = NULL;
-
- printf ("hashtable test start\n");
- hashtable = ply_hashtable_new (ply_hashtable_string_hash, ply_hashtable_string_compare);
- for (i=0; i<10; i++)
- {
- ply_hashtable_insert (hashtable, (void *) key[i], (void *) data[9-i]);
- }
- for (i=0; i<10; i++)
- {
- reply_data = ply_hashtable_lookup (hashtable, (void *) key[i]);
- printf ("got:%s\n", reply_data);
- }
- for (i=0; i<10; i++)
- {
- ply_hashtable_remove (hashtable, (void *) key[i]);
- ply_hashtable_insert (hashtable, (void *) key[i], (void *) data[i]);
- }
- for (i=0; i<10; i++)
- {
- if (ply_hashtable_lookup_full (hashtable, (void *) key[i], (void**) &reply_key, (void**) &reply_data))
- printf ("got key:%s data:%s\n", reply_key, reply_data);
- }
- ply_hashtable_foreach (hashtable, foreach_func, NULL);
- ply_hashtable_free(hashtable);
- printf ("hashtable test end\n");
- return 0;
-}
-
-#endif
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
return node->data;
}
-#ifdef PLY_LIST_ENABLE_TEST
-#include <stdio.h>
-
-static int
-compare_int_ptr (void *element_a,
- void *element_b)
-{
- int *int_a = element_a;
- int *int_b = element_b;
- return *int_a - *int_b;
-
-}
-
-int
-main (int argc,
- char **argv)
-{
- ply_list_t *list;
- ply_list_node_t *node;
- int i, lastval;
- int *value;
- int errors;
-
- errors = 0;
-
- list = ply_list_new ();
-
- ply_list_append_data (list, (void *) "foo");
- ply_list_append_data (list, (void *) "bar");
- ply_list_append_data (list, (void *) "baz");
- ply_list_prepend_data (list, (void *) "qux");
- ply_list_prepend_data (list, (void *) "quux");
- ply_list_remove_data (list, (void *) "baz");
- ply_list_remove_data (list, (void *) "foo");
-
- node = ply_list_get_first_node (list);
- i = 0;
- while (node != NULL)
- {
- printf ("node '%d' has data '%s'\n", i,
- (char *) ply_list_node_get_data (node));
- node = ply_list_get_next_node (list, node);
- i++;
- }
-
- printf ("\n");
- ply_list_remove_all_nodes (list);
- srandom(1);
-
- for (i = 0; i<100; i++)
- {
- value = malloc (sizeof (int));
- *value = random() % 100;
- ply_list_append_data (list, (void *) value);
- }
-
- ply_list_sort (list, compare_int_ptr);
-
- node = ply_list_get_first_node (list);
- i = 0;
- lastval = 0;
-
- while (node != NULL)
- {
- value = (int *) ply_list_node_get_data (node);
- if (*value < lastval)
- {
- printf ("ERROR: incorrect order\n");
- errors = 1;
- }
- lastval = *value;
- printf ("node '%d' has data '%d'\n", i, *value);
- node = ply_list_get_next_node (list, node);
- i++;
- }
-
- ply_list_free (list);
- return errors;
-}
-
-#endif
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
}
#endif /* PLY_ENABLE_TRACING */
-#ifdef PLY_LOGGER_ENABLE_TEST
-
-int
-main (int argc,
- char **argv)
-{
- int exit_code;
- ply_logger_t *logger;
-
- exit_code = 0;
- logger = ply_logger_new ();
-
- ply_logger_inject (logger, "yo yo yo\n");
- ply_logger_set_output_fd (logger, 1);
- ply_logger_inject (logger, "yo yo yo yo\n");
- ply_logger_flush (logger);
- ply_logger_free (logger);
-
- return exit_code;
-}
-
-#endif /* PLY_LOGGER_ENABLE_TEST */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
}
}
-#ifdef PLY_PROGRESS_ENABLE_TEST
-
-#include <stdio.h>
-
-int
-main (int argc,
- char **argv)
-{
- double percent;
- int slowness;
- double time;
- int i;
- const char* strings[10]={"foobar", "barfoo", "barbar", "foo", "foo", "bar", "foo", "more", "even more", "even even more"};
- ply_progress_t* progress = ply_progress_new ();
-
- progress->scalar = 1.0/5; /* Original time estimate is 5 sec*/
-
- percent = ply_progress_get_percentage (progress);
- time = ply_progress_get_time (progress);
- printf("Time:%f \t Percentage: %f%%\n", time, percent*100);
- srand ((int) ply_get_timestamp ());
-
- slowness = rand () % 500000 + 50000;
-
- for (i=0; i<2; i++)
- {
- usleep ((rand () % slowness+slowness));
- percent = ply_progress_get_percentage (progress);
- time = ply_progress_get_time (progress);
- printf("Time:%f \t Percentage: %f%%\n", time, percent*100);
- }
- printf("Load cache\n");
- ply_progress_load_cache (progress, PLYMOUTH_TIME_DIRECTORY "/boot-duration");
-
- for (i=0; i<10; i++)
- {
- ply_progress_status_update (progress, strings[i]);
- usleep ((rand () % slowness+slowness));
- percent = ply_progress_get_percentage (progress);
- time = ply_progress_get_time (progress);
- printf("Time:%f \t Percentage: %f%% \tScalar:%f\n", time, percent*100, progress->scalar);
- }
- printf("Save and free cache\n");
- ply_progress_save_cache (progress, PLYMOUTH_TIME_DIRECTORY "/boot-duration");
- ply_progress_free(progress);
-
- printf("\nManual set percentage run\n\n");
-
- progress = ply_progress_new ();
- progress->scalar = 1.0/5; /* Original time estimate is 5 sec*/
-
- percent = ply_progress_get_percentage (progress);
- time = ply_progress_get_time (progress);
- printf("Time:%f \t Percentage: %f%%\n", time, percent*100);
- srand ((int) ply_get_timestamp ());
-
- for (i=0; i<12; i++)
- {
- ply_progress_set_percentage (progress, (double)i/12);
- usleep ((rand () % slowness+slowness));
- percent = ply_progress_get_percentage (progress);
- time = ply_progress_get_time (progress);
- printf("Time:%f \t Percentage: %f%% (%f%%)\tScalar:%f\n", time, percent*100, (double)i/12*100, progress->scalar);
- }
- ply_progress_free(progress);
-
- return 0;
-}
-
-#endif /* PLY_PROGRESS_ENABLE_TEST */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
return region->rectangle_list;
}
-#ifdef PLY_REGION_ENABLE_TEST
-#include <stdio.h>
-
-#define COVER_SIZE 100
-#define RECTANGLE_COUNT 1000
-
-static void
-cover_with_rect(char cover[COVER_SIZE][COVER_SIZE],
- ply_rectangle_t *rectangle,
- char value)
-{ /* is value is not zero, the entry will be set to the value,
- otherwise entry is incremented*/
- unsigned long x, y;
- for (y=0; y<rectangle->height; y++)
- {
- for (x=0; x<rectangle->width; x++)
- {
- if (rectangle->x + x < COVER_SIZE &&
- rectangle->y + y < COVER_SIZE)
- {
- if (value)
- cover[rectangle->y + y][rectangle->x + x] = value;
- else
- cover[rectangle->y + y][rectangle->x + x]++;
- }
- }
- }
-}
-
-static int
-do_test (void)
-{
- ply_rectangle_t rectangle;
- char cover[COVER_SIZE][COVER_SIZE];
- int i;
- unsigned long x, y;
- ply_region_t *region;
- ply_list_node_t *node;
-
- region = ply_region_new ();
-
- for (y = 0; y < COVER_SIZE; y++)
- {
- for (x = 0; x < COVER_SIZE; x++)
- {
- cover[y][x] = 0;
- }
- }
-
- for (i = 0; i < RECTANGLE_COUNT; i++)
- {
- rectangle.x = random() % COVER_SIZE-5;
- rectangle.y = random() % COVER_SIZE-5;
- rectangle.width = 1 + random() % 20;
- rectangle.height = 1 + random() % 20;
- printf("Adding X=%ld Y=%ld W=%ld H=%ld\n",
- rectangle.x,
- rectangle.y,
- rectangle.width,
- rectangle.height);
- cover_with_rect(cover, &rectangle, 100); /* 100 means covered by origial squares */
- ply_region_add_rectangle (region, &rectangle);
- }
-
- printf("Converted to:\n");
- int count = 0;
-
- ply_list_t *rectangle_list = ply_region_get_rectangle_list (region);
- for (node = ply_list_get_first_node (rectangle_list);
- node;
- node = ply_list_get_next_node (rectangle_list, node))
- {
- ply_rectangle_t *small_rectangle = ply_list_node_get_data (node);
- printf("Processed X=%ld Y=%ld W=%ld H=%ld\n",
- small_rectangle->x,
- small_rectangle->y,
- small_rectangle->width,
- small_rectangle->height);
- cover_with_rect(cover, small_rectangle, 0);
- count++;
- }
- printf("Rectangles in:%d out:%d\n", RECTANGLE_COUNT, count);
-
- count=0;
-
- for (y = 0; y < COVER_SIZE; y++)
- {
- printf("%03ld ", y);
- for (x = 0; x < COVER_SIZE; x++)
- {
- if (cover[y][x] >= 100)
- {
- if (cover[y][x] == 100)
- {
- printf("-"); /* "-" means should have been covered but wasn't */
- count++;
- }
- else
- {
- if (cover[y][x] == 101)
- printf("O"); /* "O" means correctly covered */
- else
- {
- printf("%d", cover[y][x] - 101);
- count++; /* 1+ means covered multiple times*/
- }
- }
- }
- else
- {
- if (cover[y][x] == 0)
- printf("o"); /* "o" means not involved*/
- else
- {
- printf("%c", 'A' - 1 + cover[y][x]);
- count++; /* A+ means covered despite being not involved*/
- }
- }
- }
- printf("\n");
- }
- printf("errors:%d\n", count);
- return count;
-}
-int
-main (int argc,
- char **argv)
-{
- int i;
- srandom(312);
- for (i=0; i<100; i++)
- {
- if (do_test ()) return 1;
- }
- return 0;
-}
-#endif
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
return ply_logger_close_file (session->logger);
}
-#ifdef PLY_TERMINAL_SESSION_ENABLE_TEST
-
-#include <stdio.h>
-
-#include "ply-event-loop.h"
-#include "ply-terminal-session.h"
-
-static void
-on_finished (ply_event_loop_t *loop)
-{
- ply_event_loop_exit (loop, 0);
-}
-
-int
-main (int argc,
- char **argv)
-{
- ply_event_loop_t *loop;
- ply_terminal_session_t *session;
- int exit_code;
- ply_terminal_session_flags_t flags;
-
- exit_code = 0;
-
- loop = ply_event_loop_new ();
-
- session = ply_terminal_session_new ((const char * const *) (argv + 1));
-
- flags = PLY_TERMINAL_SESSION_FLAGS_RUN_IN_PARENT;
- flags |= PLY_TERMINAL_SESSION_FLAGS_LOOK_IN_PATH;
-
- ply_terminal_session_attach_to_event_loop (session, loop);
-
- if (!ply_terminal_session_run (session, flags,
- (ply_terminal_session_begin_handler_t) NULL,
- (ply_terminal_session_output_handler_t) NULL,
- (ply_terminal_session_hangup_handler_t)
- on_finished, loop))
- {
- perror ("could not start terminal session");
- return errno;
- }
-
- ply_terminal_session_open_log (session, "foo.log");
-
- exit_code = ply_event_loop_run (loop);
-
- ply_terminal_session_free (session);
-
- return exit_code;
-}
-
-#endif /* PLY_TERMINAL_SESSION_ENABLE_TEST */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
+++ /dev/null
-INCLUDES = \
- -I$(top_srcdir) \
- -I$(srcdir)/.. \
- -I$(srcdir)
-TESTS =
-
-if ENABLE_TESTS
-include $(srcdir)/ply-terminal-session-test.am
-include $(srcdir)/ply-logger-test.am
-include $(srcdir)/ply-array-test.am
-include $(srcdir)/ply-bitarray-test.am
-include $(srcdir)/ply-list-test.am
-include $(srcdir)/ply-hashtable-test.am
-include $(srcdir)/ply-event-loop-test.am
-include $(srcdir)/ply-command-parser-test.am
-include $(srcdir)/ply-progress-test.am
-include $(srcdir)/ply-region.am
-endif
-
-noinst_PROGRAMS = $(TESTS)
-
-# Our tests aren't unit tests so clear for now
-TESTS =
-
-MAINTAINERCLEANFILES = Makefile.in
+++ /dev/null
-TESTS += ply-array-test
-
-ply_array_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_ARRAY_ENABLE_TEST
-ply_array_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_array_test_SOURCES = \
- $(srcdir)/../ply-buffer.h \
- $(srcdir)/../ply-buffer.c \
- $(srcdir)/../ply-list.h \
- $(srcdir)/../ply-list.c \
- $(srcdir)/../ply-logger.h \
- $(srcdir)/../ply-logger.c \
- $(srcdir)/../ply-utils.h \
- $(srcdir)/../ply-utils.c \
- $(srcdir)/../ply-array.h \
- $(srcdir)/../ply-array.c
+++ /dev/null
-TESTS += ply-bitarray-test
-
-ply_bitarray_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BITARRAY_ENABLE_TEST
-ply_bitarray_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_bitarray_test_SOURCES = \
- $(srcdir)/../ply-bitarray.h \
- $(srcdir)/../ply-bitarray.c
+++ /dev/null
-TESTS += ply-command-parser-test
-
-ply_command_parser_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_COMMAND_PARSER_ENABLE_TEST
-ply_command_parser_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_command_parser_test_SOURCES = \
- $(srcdir)/../ply-buffer.h \
- $(srcdir)/../ply-buffer.c \
- $(srcdir)/../ply-event-loop.h \
- $(srcdir)/../ply-event-loop.c \
- $(srcdir)/../ply-list.h \
- $(srcdir)/../ply-list.c \
- $(srcdir)/../ply-logger.h \
- $(srcdir)/../ply-logger.c \
- $(srcdir)/../ply-utils.h \
- $(srcdir)/../ply-utils.c \
- $(srcdir)/../ply-command-parser.h \
- $(srcdir)/../ply-command-parser.c
+++ /dev/null
-TESTS += ply-event-loop-test
-
-ply_event_loop_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_EVENT_LOOP_ENABLE_TEST
-ply_event_loop_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_event_loop_test_SOURCES = \
- $(srcdir)/../ply-utils.h \
- $(srcdir)/../ply-utils.c \
- $(srcdir)/../ply-list.h \
- $(srcdir)/../ply-list.c \
- $(srcdir)/../ply-logger.h \
- $(srcdir)/../ply-logger.c \
- $(srcdir)/../ply-event-loop.h \
- $(srcdir)/../ply-event-loop.c
+++ /dev/null
-TESTS += ply-hashtable-test
-
-ply_hashtable_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_HASHTABLE_ENABLE_TEST
-ply_hashtable_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_hashtable_test_SOURCES = \
- $(srcdir)/../ply-hashtable.h \
- $(srcdir)/../ply-hashtable.c \
- $(srcdir)/../ply-bitarray.h \
- $(srcdir)/../ply-bitarray.c
+++ /dev/null
-TESTS += ply-list-test
-
-ply_list_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_LIST_ENABLE_TEST
-ply_list_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_list_test_SOURCES = \
- $(srcdir)/../ply-list.h \
- $(srcdir)/../ply-list.c
+++ /dev/null
-TESTS += ply-logger-test
-
-ply_logger_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_LOGGER_ENABLE_TEST
-ply_logger_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_logger_test_SOURCES = \
- $(srcdir)/../ply-list.h \
- $(srcdir)/../ply-list.c \
- $(srcdir)/../ply-utils.h \
- $(srcdir)/../ply-utils.c \
- $(srcdir)/../ply-logger.h \
- $(srcdir)/../ply-logger.c
+++ /dev/null
-TESTS += ply-progress-test
-
-ply_progress_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_PROGRESS_ENABLE_TEST \
- -DPLYMOUTH_TIME_DIRECTORY=\"$(localstatedir)/lib/plymouth/\"
-ply_progress_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_progress_test_SOURCES = \
- $(srcdir)/../ply-progress.h \
- $(srcdir)/../ply-progress.c \
- $(srcdir)/../ply-list.h \
- $(srcdir)/../ply-list.c \
- $(srcdir)/../ply-logger.h \
- $(srcdir)/../ply-logger.c \
- $(srcdir)/../ply-utils.h \
- $(srcdir)/../ply-utils.c
+++ /dev/null
-TESTS += ply-region-test
-
-ply_region_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_REGION_ENABLE_TEST
-ply_region_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_region_test_SOURCES = \
- $(srcdir)/../ply-region.h \
- $(srcdir)/../ply-region.c \
- $(srcdir)/../ply-rectangle.h \
- $(srcdir)/../ply-rectangle.c \
- $(srcdir)/../ply-list.h \
- $(srcdir)/../ply-list.c
+++ /dev/null
-TESTS += ply-terminal-session-test
-
-ply_terminal_session_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_TERMINAL_SESSION_ENABLE_TEST
-ply_terminal_session_test_LDADD = $(PLYMOUTH_LIBS)
-
-ply_terminal_session_test_SOURCES = \
- $(srcdir)/../ply-utils.h \
- $(srcdir)/../ply-utils.c \
- $(srcdir)/../ply-buffer.h \
- $(srcdir)/../ply-buffer.c \
- $(srcdir)/../ply-logger.h \
- $(srcdir)/../ply-logger.c \
- $(srcdir)/../ply-list.h \
- $(srcdir)/../ply-list.c \
- $(srcdir)/../ply-event-loop.h \
- $(srcdir)/../ply-event-loop.c \
- $(srcdir)/../ply-terminal-session.h \
- $(srcdir)/../ply-terminal-session.c
server);
}
-#ifdef PLY_BOOT_SERVER_ENABLE_TEST
-
-#include <stdio.h>
-
-#include "ply-event-loop.h"
-#include "ply-boot-server.h"
-
-static void
-on_update (ply_event_loop_t *loop,
- const char *status)
-{
- printf ("new status is '%s'\n", status);
-}
-
-static void
-on_newroot (ply_event_loop_t *loop)
-{
- printf ("got newroot request\n");
-}
-
-static void
-on_system_initialized (ply_event_loop_t *loop)
-{
- printf ("got sysinit done request\n");
-}
-
-static void
-on_show_splash (ply_event_loop_t *loop)
-{
- printf ("got show splash request\n");
-}
-
-static void
-on_hide_splash (ply_event_loop_t *loop)
-{
- printf ("got hide splash request\n");
-}
-
-static void
-on_deactivate (ply_event_loop_t *loop)
-{
- printf ("got deactivate request\n");
-}
-
-static void
-on_reactivate (ply_event_loop_t *loop)
-{
- printf ("got reactivate request\n");
-}
-
-static void
-on_quit (ply_event_loop_t *loop)
-{
- printf ("got quit request, quiting...\n");
- ply_event_loop_exit (loop, 0);
-}
-
-static void
-on_error (ply_event_loop_t *loop)
-{
- printf ("got error starting service\n");
-}
-
-static char *
-on_ask_for_password (ply_event_loop_t *loop)
-{
- printf ("got password request, returning 'password'...\n");
-
- return strdup ("password");
-}
-
-static void
-on_ask_question (ply_event_loop_t *loop)
-{
- printf ("got question request\n");
- return;
-}
-
-static void
-on_display_message (ply_event_loop_t *loop)
-{
- printf ("got display message request\n");
- return;
-}
-
-static void
-on_hide_message (ply_event_loop_t *loop)
-{
- printf ("got hide message request\n");
- return;
-}
-
-static void
-on_watch_for_keystroke (ply_event_loop_t *loop)
-{
- printf ("got keystroke request\n");
-
- return;
-}
-
-static void
-on_progress_pause (ply_event_loop_t *loop)
-{
- printf ("got progress pause request\n");
-
- return;
-}
-
-static void
-on_progress_unpause (ply_event_loop_t *loop)
-{
- printf ("got progress unpause request\n");
-
- return;
-}
-
-static void
-on_ignore_keystroke (ply_event_loop_t *loop)
-{
- printf ("got keystroke ignore request\n");
-
- return;
-}
-
-static bool
-on_has_active_vt (ply_event_loop_t *loop)
-{
- printf ("got has_active vt? request\n");
- return true;
-}
-
-int
-main (int argc,
- char **argv)
-{
- ply_event_loop_t *loop;
- ply_boot_server_t *server;
- int exit_code;
-
- exit_code = 0;
-
- loop = ply_event_loop_new ();
-
- server = ply_boot_server_new ((ply_boot_server_update_handler_t) on_update,
- (ply_boot_server_change_mode_handler_t) on_change_mode,
- (ply_boot_server_system_update_handler_t) on_system_update,
- (ply_boot_server_ask_for_password_handler_t) on_ask_for_password,
- (ply_boot_server_ask_question_handler_t) on_ask_question,
- (ply_boot_server_display_message_handler_t) on_display_message,
- (ply_boot_server_hide_message_handler_t) on_hide_message,
- (ply_boot_server_watch_for_keystroke_handler_t) on_watch_for_keystroke,
- (ply_boot_server_ignore_keystroke_handler_t) on_ignore_keystroke,
- (ply_boot_server_progress_pause_handler_t) on_progress_pause,
- (ply_boot_server_progress_unpause_handler_t) on_progress_unpause,
- (ply_boot_server_show_splash_handler_t) on_show_splash,
- (ply_boot_server_hide_splash_handler_t) on_hide_splash,
- (ply_boot_server_newroot_handler_t) on_newroot,
- (ply_boot_server_system_initialized_handler_t) on_system_initialized,
- (ply_boot_server_error_handler_t) on_error,
- (ply_boot_server_deactivate_handler_t) on_deactivate,
- (ply_boot_server_reactivate_handler_t) on_reactivate,
- (ply_boot_server_quit_handler_t) on_quit,
- (ply_boot_server_has_active_vt_handler_t) on_has_active_vt,
- loop);
-
- if (!ply_boot_server_listen (server))
- {
- perror ("could not start boot status daemon");
- return errno;
- }
-
- ply_boot_server_attach_to_event_loop (server, loop);
- exit_code = ply_event_loop_run (loop);
- ply_boot_server_free (server);
-
- return exit_code;
-}
-
-#endif /* PLY_BOOT_SERVER_ENABLE_TEST */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
+++ /dev/null
-INCLUDES = \
- -I$(top_srcdir) \
- -I$(srcdir)/.. \
- -I$(srcdir)/../libply \
- -I$(srcdir)/../libply-splash-core \
- -I$(srcdir)
-TESTS =
-
-if ENABLE_TESTS
-include $(srcdir)/ply-boot-server-test.am
-include $(srcdir)/ply-boot-splash-test.am
-endif
-
-noinst_PROGRAMS = $(TESTS)
-
-# our tests aren't unit tests, so clear for now
-TESTS =
-MAINTAINERCLEANFILES = Makefile.in
+++ /dev/null
-TESTS += ply-boot-server-test
-
-ply_boot_server_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BOOT_SERVER_ENABLE_TEST
-ply_boot_server_test_LDADD = $(PLYMOUTH_LIBS) ../libply/libply.la
-
-ply_boot_server_test_SOURCES = \
- $(srcdir)/../ply-boot-server.h \
- $(srcdir)/../ply-boot-server.c
+++ /dev/null
-TESTS += ply-boot-splash-test
-
-ply_boot_splash_test_CFLAGS = $(PLYMOUTH_CFLAGS) -DPLY_BOOT_SPLASH_ENABLE_TEST \
- -DPLYMOUTH_TIME_DIRECTORY=\"/var/lib/plymouth\" \
- -DPLYMOUTH_PLUGIN_PATH=\"$(PLYMOUTH_PLUGIN_PATH)\" \
- -DPLYMOUTH_THEME_PATH=\"$(PLYMOUTH_THEME_PATH)/\"
-
-ply_boot_splash_test_LDADD = $(PLYMOUTH_LIBS) ../libply/libply.la
-
-ply_boot_splash_test_SOURCES = \
- $(srcdir)/../libply-splash-core/ply-boot-splash-plugin.h \
- $(srcdir)/../libply-splash-core/ply-keyboard.h \
- $(srcdir)/../libply-splash-core/ply-keyboard.c \
- $(srcdir)/../libply-splash-core/ply-pixel-buffer.h \
- $(srcdir)/../libply-splash-core/ply-pixel-buffer.c \
- $(srcdir)/../libply-splash-core/ply-pixel-display.h \
- $(srcdir)/../libply-splash-core/ply-pixel-display.c \
- $(srcdir)/../libply-splash-core/ply-renderer.h \
- $(srcdir)/../libply-splash-core/ply-renderer.c \
- $(srcdir)/../libply-splash-core/ply-terminal.h \
- $(srcdir)/../libply-splash-core/ply-terminal.c \
- $(srcdir)/../libply-splash-core/ply-text-display.h \
- $(srcdir)/../libply-splash-core/ply-text-display.c \
- $(srcdir)/../libply-splash-core/ply-boot-splash.h \
- $(srcdir)/../libply-splash-core/ply-boot-splash.c