Skip to content

Commit

Permalink
WIP: tests
Browse files Browse the repository at this point in the history
Signed-off-by: Yury V. Zaytsev <[email protected]>
  • Loading branch information
zyv committed Oct 3, 2024
1 parent bfac9d3 commit 9527c41
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 31 deletions.
4 changes: 2 additions & 2 deletions lib/mcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ gchar **mc_config_get_keys (const mc_config_t * mc_config, const gchar * group,
gchar *mc_config_get_string (mc_config_t * mc_config, const gchar * group, const gchar * param,
const gchar * def);
gchar *mc_config_get_string_raw (mc_config_t * mc_config, const gchar * group, const gchar * param,
const gchar * def);
const gchar * def) __attribute__((weak));
gboolean mc_config_get_bool (mc_config_t * mc_config, const gchar * group, const gchar * param,
gboolean def);
int mc_config_get_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int def);
Expand Down Expand Up @@ -96,7 +96,7 @@ void mc_config_deinit_config_paths (void);

const char *mc_config_get_data_path (void);
const char *mc_config_get_cache_path (void);
const char *mc_config_get_home_dir (void);
const char *mc_config_get_home_dir (void) __attribute__((weak));
const char *mc_config_get_path (void);
char *mc_config_get_full_path (const char *config_name);
vfs_path_t *mc_config_get_full_vpath (const char *config_name);
Expand Down
4 changes: 2 additions & 2 deletions lib/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void mc_pclose (mc_pipe_t * p, GError ** error);

GString *mc_pstream_get_string (mc_pipe_stream_t * ps);

void my_exit (int status);
void my_exit (int status) __attribute__((weak));
void save_stop_handler (void);

/* Tilde expansion */
Expand Down Expand Up @@ -249,7 +249,7 @@ gboolean mc_util_make_backup_if_possible (const char *file_name, const char *bac
gboolean mc_util_restore_from_backup_if_possible (const char *file_name, const char *backup_suffix);
gboolean mc_util_unlink_backup_if_possible (const char *file_name, const char *backup_suffix);

char *guess_message_value (void);
char *guess_message_value (void) __attribute__((weak));

char *mc_build_filename (const char *first_element, ...);
char *mc_build_filenamev (const char *first_element, va_list args);
Expand Down
2 changes: 1 addition & 1 deletion lib/vfs/utilvfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ vfs_path_element_t *vfs_url_split (const char *path, int default_port, vfs_url_f
int vfs_split_text (char *p);

int vfs_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *basename);
void vfs_die (const char *msg);
void vfs_die (const char *msg) __attribute__((weak));
char *vfs_get_password (const char *msg);

char *vfs_get_local_username (void);
Expand Down
10 changes: 5 additions & 5 deletions lib/vfs/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ const vfs_path_t *vfs_get_raw_current_dir (void);
void vfs_set_raw_current_dir (const vfs_path_t * vpath);

gboolean vfs_current_is_local (void);
gboolean vfs_file_is_local (const vfs_path_t * vpath);
gboolean vfs_file_is_local (const vfs_path_t * vpath) __attribute__((weak));

char *vfs_strip_suffix_from_filename (const char *filename);

Expand Down Expand Up @@ -318,13 +318,13 @@ off_t mc_lseek (int fd, off_t offset, int whence);
DIR *mc_opendir (const vfs_path_t * vpath);
struct vfs_dirent *mc_readdir (DIR * dirp);
int mc_closedir (DIR * dir);
int mc_stat (const vfs_path_t * vpath, struct stat *buf);
int mc_stat (const vfs_path_t * vpath, struct stat *buf) __attribute__((weak));
int mc_mknod (const vfs_path_t * vpath, mode_t mode, dev_t dev);
int mc_link (const vfs_path_t * vpath1, const vfs_path_t * vpath2);
int mc_mkdir (const vfs_path_t * vpath, mode_t mode);
int mc_rmdir (const vfs_path_t * vpath);
int mc_fstat (int fd, struct stat *buf);
int mc_lstat (const vfs_path_t * vpath, struct stat *buf);
int mc_lstat (const vfs_path_t * vpath, struct stat *buf) __attribute__((weak));
int mc_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2);
int mc_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2);
int mc_chmod (const vfs_path_t * vpath, mode_t mode);
Expand All @@ -336,9 +336,9 @@ int mc_unlink (const vfs_path_t * vpath);
int mc_ctl (int fd, int ctlop, void *arg);
int mc_setctl (const vfs_path_t * vpath, int ctlop, void *arg);
int mc_open (const vfs_path_t * vpath, int flags, ...);
vfs_path_t *mc_getlocalcopy (const vfs_path_t * pathname_vpath);
vfs_path_t *mc_getlocalcopy (const vfs_path_t * pathname_vpath) __attribute__((weak));
int mc_ungetlocalcopy (const vfs_path_t * pathname_vpath, const vfs_path_t * local_vpath,
gboolean has_changed);
gboolean has_changed) __attribute__((weak));
int mc_mkstemps (vfs_path_t ** pname_vpath, const char *prefix, const char *suffix);

/* Creating temporary files safely */
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/dialog-switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void dialog_switch_shutdown (void);
void do_refresh (void);

void repaint_screen (void);
void mc_refresh (void);
void mc_refresh (void) __attribute__((weak));
void dialog_change_screen_size (void);

/*** inline functions ****************************************************************************/
Expand Down
3 changes: 2 additions & 1 deletion lib/widget/input_complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ typedef struct

/*** forward declarations (file scope functions) *************************************************/

GPtrArray *try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags);
GPtrArray *try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
__attribute__((weak));
void complete_engine_fill_completions (WInput * in);

/*** file scope variables ************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/wtools.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ WDialog *create_message (int flags, const char *title, const char *text, ...)
G_GNUC_PRINTF (3, 4);

/* Show message box, background safe */
void message (int flags, const char *title, const char *text, ...) G_GNUC_PRINTF (3, 4);
void message (int flags, const char *title, const char *text, ...) G_GNUC_PRINTF (3, 4) __attribute__((weak));
/* *INDENT-ON* */

gboolean mc_error_message (GError ** mcerror, int *code);
Expand Down
10 changes: 1 addition & 9 deletions m4.include/mc-tests.m4
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,7 @@ AC_DEFUN([mc_UNIT_TESTS],[
#include <signal.h>
])
# on cygwin, the linker does not accept the "-z" option
case $host_os in
cygwin*)
TESTS_LDFLAGS="-Wl,--allow-multiple-definition"
;;
*)
TESTS_LDFLAGS="-Wl,-z,muldefs"
;;
esac
# TODO: check weak attribute?
AC_SUBST(TESTS_LDFLAGS)
])
4 changes: 2 additions & 2 deletions src/editor/edit-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ void edit_paste_from_history (WEdit * edit);

void edit_set_filename (WEdit * edit, const vfs_path_t * name_vpath);

void edit_load_syntax (WEdit * edit, GPtrArray * pnames, const char *type);
void edit_load_syntax (WEdit * edit, GPtrArray * pnames, const char *type) __attribute__((weak));
void edit_free_syntax_rules (WEdit * edit);
int edit_get_syntax_color (WEdit * edit, off_t byte_index);
int edit_get_syntax_color (WEdit * edit, off_t byte_index) __attribute__((weak));
void edit_syntax_dialog (WEdit * edit);

void book_mark_insert (WEdit * edit, long line, int c);
Expand Down
3 changes: 2 additions & 1 deletion src/editor/editcomplete.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
/*** declarations of public functions ************************************************************/

/* Public function for unit tests */
char *edit_completion_dialog_show (const WEdit * edit, GQueue * compl, int max_width);
char *edit_completion_dialog_show (const WEdit * edit, GQueue * compl, int max_width)
__attribute__((weak));

void edit_complete_word_cmd (WEdit * edit);

Expand Down
2 changes: 1 addition & 1 deletion src/editor/editmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/*** declarations of public functions ************************************************************/

int edit_store_macro_cmd (WEdit * edit);
gboolean edit_load_macro_cmd (WEdit * edit);
gboolean edit_load_macro_cmd (WEdit * edit) __attribute__((weak));
void edit_delete_macro_cmd (WEdit * edit);
gboolean edit_repeat_macro_cmd (WEdit * edit);
gboolean edit_execute_macro (WEdit * edit, int hotkey);
Expand Down
6 changes: 3 additions & 3 deletions src/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ int pause_after_run = pause_on_dumb_terminals;

/*** forward declarations (file scope functions) *************************************************/

void do_execute (const char *shell, const char *command, int flags);
void do_executev (const char *shell, int flags, char *const argv[]);
void do_execute (const char *shell, const char *command, int flags) __attribute__((weak));
void do_executev (const char *shell, int flags, char *const argv[]) __attribute__((weak));
char *execute_get_external_cmd_opts_from_config (const char *command,
const vfs_path_t * filename_vpath,
long start_line);
long start_line) __attribute__((weak));

/*** file scope variables ************************************************************************/

Expand Down
2 changes: 1 addition & 1 deletion src/filemanager/layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void setup_cmdline (void);
void create_panel (int num, panel_view_mode_t type);
void swap_panels (void);
panel_view_mode_t get_panel_type (int idx);
panel_view_mode_t get_current_type (void);
panel_view_mode_t get_current_type (void) __attribute__((weak));
panel_view_mode_t get_other_type (void);
int get_current_index (void);
int get_other_index (void);
Expand Down
3 changes: 2 additions & 1 deletion src/filemanager/panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ void file_mark (WPanel * panel, int idx, int val);
void do_file_mark (WPanel * panel, int idx, int val);

gboolean panel_do_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
gboolean panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_type);
gboolean panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_type)
__attribute__((weak));

gsize panel_get_num_of_sortable_fields (void);
char **panel_get_sortable_fields (gsize * array_size);
Expand Down
4 changes: 4 additions & 0 deletions tests/lib/utilunix__my_system-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ static sigset_t *sigemptyset_set__captured;
/* @ThenReturnValue */
static int sigemptyset__return_value = 0;

#ifdef sigemptyset
#undef sigemptyset
#endif

/* @Mock */
int
sigemptyset (sigset_t *set)
Expand Down

0 comments on commit 9527c41

Please sign in to comment.