Skip to content

Commit eb9422f

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 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 3fcc433 commit eb9422f

File tree

8 files changed

+2776
-7
lines changed

8 files changed

+2776
-7
lines changed

Makefile

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

16901690
PROGRAM_OBJS += gvfs-helper.o
1691+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
16911692

16921693
REMOTE_CURL_PRIMARY = git-remote-http$X
16931694
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X

bin-wrappers/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
/git-upload-pack
77
/scalar
88
/test-fake-ssh
9+
/test-gvfs-protocol
910
/test-tool

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
@@ -1885,6 +1885,8 @@ static void install_loose(struct gh__request_params *params,
18851885
/*
18861886
* We expect a loose object when we do a GET -or- when we
18871887
* do a POST with only 1 object.
1888+
*
1889+
* Note that this content type is singular, not plural.
18881890
*/
18891891
if (strcmp(status->content_type.buf,
18901892
"application/x-git-loose-object")) {
@@ -2119,14 +2121,17 @@ static void do_throttle_spin(struct gh__request_params *params,
21192121
strbuf_addstr(&region, gh__server_type_label[params->server_type]);
21202122
trace2_region_enter("gvfs-helper", region.buf, NULL);
21212123

2122-
progress = start_progress(progress_msg, duration);
2124+
if (gh__cmd_opts.show_progress)
2125+
progress = start_progress(progress_msg, duration);
2126+
21232127
while (now < end) {
21242128
display_progress(progress, (now - begin));
21252129

21262130
sleep_millisec(100);
21272131

21282132
now = time(NULL);
21292133
}
2134+
21302135
display_progress(progress, duration);
21312136
stop_progress(&progress);
21322137

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

t/helper/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ test_tool = executable('test-tool',
8686
bin_wrappers += test_tool
8787
test_dependencies += test_tool
8888

89+
test_gvfs_protocol = executable('test-gvfs-protocol',
90+
sources: 'test-gvfs-protocol.c',
91+
dependencies: [libgit, common_main],
92+
)
93+
bin_wrappers += test_gvfs_protocol
94+
test_dependencies += test_gvfs_protocol
95+
8996
test_fake_ssh = executable('test-fake-ssh',
9097
sources: 'test-fake-ssh.c',
9198
dependencies: [libgit, common_main],

0 commit comments

Comments
 (0)