Skip to content

Commit 0c7e59f

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 192dc5f commit 0c7e59f

File tree

8 files changed

+2786
-7
lines changed

8 files changed

+2786
-7
lines changed

Makefile

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

17011701
PROGRAM_OBJS += gvfs-helper.o
1702+
TEST_PROGRAMS_NEED_X += test-gvfs-protocol
17021703

17031704
REMOTE_CURL_PRIMARY = git-remote-http$X
17041705
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
@@ -1123,6 +1123,20 @@ set(wrapper_scripts
11231123
set(wrapper_test_scripts
11241124
test-fake-ssh test-tool)
11251125

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

11271141
foreach(script ${wrapper_scripts})
11281142
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(the_repository, progress_msg, duration);
2124+
if (gh__cmd_opts.show_progress)
2125+
progress = start_progress(the_repository, 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

@@ -2695,13 +2700,15 @@ static void do__http_post__gvfs_objects(struct gh__response_status *status,
26952700
params.headers = curl_slist_append(params.headers,
26962701
"Content-Type: application/json");
26972702
/*
2698-
* We really always want a packfile. But if the payload only
2699-
* requests 1 OID, the server will send us a single loose
2700-
* objects instead. (Apparently the server ignores us when we
2701-
* only send application/x-git-packfile and does it anyway.)
2703+
* If our POST contains more than one object, we want the
2704+
* server to send us a packfile. We DO NOT want the non-standard
2705+
* concatenated loose object format, so we DO NOT send:
2706+
* "Accept: application/x-git-loose-objects" (plural)
27022707
*
2703-
* So to make it clear to my future self, go ahead and add
2704-
* an accept header for loose objects and own it.
2708+
* However, if the payload only requests 1 OID, the server
2709+
* will send us a single loose object instead of a packfile,
2710+
* so we ACK that and send:
2711+
* "Accept: application/x-git-loose-object" (singular)
27052712
*/
27062713
params.headers = curl_slist_append(params.headers,
27072714
"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_commonmain],
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_commonmain],

0 commit comments

Comments
 (0)