Skip to content

Commit 02f963d

Browse files
jeffhostetlerdscho
authored andcommitted
test-gvfs-prococol, t5799: tests for gvfs-helper
Create t/helper/test-gvfs-protocol.c and t/t5799-gvfs-helper.sh to test gvfs-helper. Create t/helper/test-gvfs-protocol.c as a stand-alone web server that speaks the GVFS Protocol [1] and serves loose objects and packfiles to clients. It is borrows heavily from the code in daemon.c. It includes a "mayhem" mode to cause various network and HTTP errors to test the retry/recovery ability of gvfs-helper. Create t/t5799-gvfs-helper.sh to test gvfs-helper. [1] https://github.com/microsoft/VFSForGit/blob/master/Protocol.md Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 8c40f07 commit 02f963d

File tree

5 files changed

+2763
-7
lines changed

5 files changed

+2763
-7
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,7 @@ endif
16841684
BASIC_CFLAGS += $(CURL_CFLAGS)
16851685

16861686
PROGRAM_OBJS += gvfs-helper.o
1687+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
16871688

16881689
REMOTE_CURL_PRIMARY = git-remote-http$X
16891690
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X

contrib/buildsystems/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,20 @@ set(wrapper_scripts
11191119
set(wrapper_test_scripts
11201120
test-fake-ssh test-tool)
11211121

1122+
if(CURL_FOUND)
1123+
list(APPEND wrapper_test_scripts test-gvfs-protocol)
1124+
1125+
add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
1126+
target_link_libraries(test-gvfs-protocol common-main)
1127+
1128+
if(MSVC)
1129+
set_target_properties(test-gvfs-protocol
1130+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
1131+
set_target_properties(test-gvfs-protocol
1132+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
1133+
endif()
1134+
endif()
1135+
11221136

11231137
foreach(script ${wrapper_scripts})
11241138
file(STRINGS ${CMAKE_SOURCE_DIR}/bin-wrappers/wrap-for-bin.sh content NEWLINE_CONSUME)

gvfs-helper.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,8 @@ static void install_loose(struct gh__request_params *params,
18831883
/*
18841884
* We expect a loose object when we do a GET -or- when we
18851885
* do a POST with only 1 object.
1886+
*
1887+
* Note that this content type is singular, not plural.
18861888
*/
18871889
if (strcmp(status->content_type.buf,
18881890
"application/x-git-loose-object")) {
@@ -2117,14 +2119,17 @@ static void do_throttle_spin(struct gh__request_params *params,
21172119
strbuf_addstr(&region, gh__server_type_label[params->server_type]);
21182120
trace2_region_enter("gvfs-helper", region.buf, NULL);
21192121

2120-
progress = start_progress(progress_msg, duration);
2122+
if (gh__cmd_opts.show_progress)
2123+
progress = start_progress(progress_msg, duration);
2124+
21212125
while (now < end) {
21222126
display_progress(progress, (now - begin));
21232127

21242128
sleep_millisec(100);
21252129

21262130
now = time(NULL);
21272131
}
2132+
21282133
display_progress(progress, duration);
21292134
stop_progress(&progress);
21302135

@@ -2680,13 +2685,15 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
26802685
params.headers = curl_slist_append(params.headers,
26812686
"Content-Type: application/json");
26822687
/*
2683-
* We really always want a packfile. But if the payload only
2684-
* requests 1 OID, the server will send us a single loose
2685-
* objects instead. (Apparently the server ignores us when we
2686-
* only send application/x-git-packfile and does it anyway.)
2688+
* If our POST contains more than one object, we want the
2689+
* server to send us a packfile. We DO NOT want the non-standard
2690+
* concatenated loose object format, so we DO NOT send:
2691+
* "Accept: application/x-git-loose-objects" (plural)
26872692
*
2688-
* So to make it clear to my future self, go ahead and add
2689-
* an accept header for loose objects and own it.
2693+
* However, if the payload only requests 1 OID, the server
2694+
* will send us a single loose object instead of a packfile,
2695+
* so we ACK that and send:
2696+
* "Accept: application/x-git-loose-object" (singular)
26902697
*/
26912698
params.headers = curl_slist_append(params.headers,
26922699
"Accept: application/x-git-packfile");

0 commit comments

Comments
 (0)