Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
GNOME
libsecret
Commits
9cfad7c6
Commit
9cfad7c6
authored
Aug 15, 2019
by
Daiki Ueno
Committed by
Daiki Ueno
Oct 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
egg-testing: Sync with gnome-keyring
parent
29cc1415
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
1 deletion
+77
-1
egg/egg-testing.c
egg/egg-testing.c
+68
-0
egg/egg-testing.h
egg/egg-testing.h
+9
-1
No files found.
egg/egg-testing.c
View file @
9cfad7c6
...
...
@@ -171,3 +171,71 @@ egg_tests_run_with_loop (void)
return
ret
;
}
void
egg_tests_copy_scratch_file
(
const
gchar
*
directory
,
const
gchar
*
filename
)
{
GError
*
error
=
NULL
;
gchar
*
basename
;
gchar
*
contents
;
gchar
*
destination
;
gsize
length
;
g_assert
(
directory
);
g_file_get_contents
(
filename
,
&
contents
,
&
length
,
&
error
);
g_assert_no_error
(
error
);
basename
=
g_path_get_basename
(
filename
);
destination
=
g_build_filename
(
directory
,
basename
,
NULL
);
g_free
(
basename
);
g_file_set_contents
(
destination
,
contents
,
length
,
&
error
);
g_assert_no_error
(
error
);
g_free
(
destination
);
g_free
(
contents
);
}
gchar
*
egg_tests_create_scratch_directory
(
const
gchar
*
file_to_copy
,
...)
{
gchar
*
basename
;
gchar
*
directory
;
va_list
va
;
basename
=
g_path_get_basename
(
g_get_prgname
());
directory
=
g_strdup_printf
(
"/tmp/scratch-%s.XXXXXX"
,
basename
);
g_free
(
basename
);
if
(
!
g_mkdtemp
(
directory
))
g_assert_not_reached
();
va_start
(
va
,
file_to_copy
);
while
(
file_to_copy
!=
NULL
)
{
egg_tests_copy_scratch_file
(
directory
,
file_to_copy
);
file_to_copy
=
va_arg
(
va
,
const
gchar
*
);
}
va_end
(
va
);
return
directory
;
}
void
egg_tests_remove_scratch_directory
(
const
gchar
*
directory
)
{
gchar
*
argv
[]
=
{
"rm"
,
"-rf"
,
(
gchar
*
)
directory
,
NULL
};
GError
*
error
=
NULL
;
gint
rm_status
;
g_assert_cmpstr
(
directory
,
!=
,
""
);
g_assert_cmpstr
(
directory
,
!=
,
"/"
);
g_spawn_sync
(
NULL
,
argv
,
NULL
,
G_SPAWN_SEARCH_PATH
,
NULL
,
NULL
,
NULL
,
NULL
,
&
rm_status
,
&
error
);
g_assert_no_error
(
error
);
g_assert_cmpint
(
rm_status
,
==
,
0
);
}
egg/egg-testing.h
View file @
9cfad7c6
...
...
@@ -56,4 +56,12 @@ void egg_test_wait_idle (void);
gint
egg_tests_run_with_loop
(
void
);
#endif
/* EGG_DH_H_ */
void
egg_tests_copy_scratch_file
(
const
gchar
*
directory
,
const
gchar
*
file_to_copy
);
gchar
*
egg_tests_create_scratch_directory
(
const
gchar
*
file_to_copy
,
...)
G_GNUC_NULL_TERMINATED
;
void
egg_tests_remove_scratch_directory
(
const
gchar
*
directory
);
#endif
/* EGG_TESTING_H_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment