Skip to content

Commit 5723160

Browse files
jeffhostetlervdye
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>
1 parent bece812 commit 5723160

5 files changed

Lines changed: 2759 additions & 7 deletions

File tree

Makefile

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

16351635
PROGRAM_OBJS += gvfs-helper.o
1636+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
16361637

16371638
REMOTE_CURL_PRIMARY = git-remote-http$X
16381639
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
@@ -1029,6 +1029,20 @@ set(wrapper_scripts
10291029
set(wrapper_test_scripts
10301030
test-fake-ssh test-tool)
10311031

1032+
if(CURL_FOUND)
1033+
list(APPEND wrapper_test_scripts test-gvfs-protocol)
1034+
1035+
add_executable(test-gvfs-protocol ${CMAKE_SOURCE_DIR}/t/helper/test-gvfs-protocol.c)
1036+
target_link_libraries(test-gvfs-protocol common-main)
1037+
1038+
if(MSVC)
1039+
set_target_properties(test-gvfs-protocol
1040+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/t/helper)
1041+
set_target_properties(test-gvfs-protocol
1042+
PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/t/helper)
1043+
endif()
1044+
endif()
1045+
10321046

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

gvfs-helper.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,8 @@ static void install_loose(struct gh__request_params *params,
18801880
/*
18811881
* We expect a loose object when we do a GET -or- when we
18821882
* do a POST with only 1 object.
1883+
*
1884+
* Note that this content type is singular, not plural.
18831885
*/
18841886
if (strcmp(status->content_type.buf,
18851887
"application/x-git-loose-object")) {
@@ -2114,14 +2116,17 @@ static void do_throttle_spin(struct gh__request_params *params,
21142116
strbuf_addstr(&region, gh__server_type_label[params->server_type]);
21152117
trace2_region_enter("gvfs-helper", region.buf, NULL);
21162118

2117-
progress = start_progress(progress_msg, duration);
2119+
if (gh__cmd_opts.show_progress)
2120+
progress = start_progress(progress_msg, duration);
2121+
21182122
while (now < end) {
21192123
display_progress(progress, (now - begin));
21202124

21212125
sleep_millisec(100);
21222126

21232127
now = time(NULL);
21242128
}
2129+
21252130
display_progress(progress, duration);
21262131
stop_progress(&progress);
21272132

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

0 commit comments

Comments
 (0)