From patchwork Fri Nov 7 17:06:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 5254521 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 116ED9F387 for ; Fri, 7 Nov 2014 17:06:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A1AD20107 for ; Fri, 7 Nov 2014 17:06:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D6A3020117 for ; Fri, 7 Nov 2014 17:06:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752406AbaKGRGW (ORCPT ); Fri, 7 Nov 2014 12:06:22 -0500 Received: from cantor2.suse.de ([195.135.220.15]:53786 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496AbaKGRGV (ORCPT ); Fri, 7 Nov 2014 12:06:21 -0500 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 632C7AC89 for ; Fri, 7 Nov 2014 17:06:20 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id B7A31DABF5; Fri, 7 Nov 2014 18:06:19 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 1/5] btrfs-progs: build, add basic build test for library Date: Fri, 7 Nov 2014 18:06:19 +0100 Message-Id: X-Mailer: git-send-email 2.1.3 In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Basic test based on snapper code that uses the send stream API. Signed-off-by: David Sterba --- Makefile | 8 +++++++ library-test.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 library-test.c diff --git a/Makefile b/Makefile index 203597c3e23e..99b03658a406 100644 --- a/Makefile +++ b/Makefile @@ -240,6 +240,14 @@ send-test: $(objects) $(libs) send-test.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o send-test $(objects) send-test.o $(LDFLAGS) $(LIBS) -lpthread +library-test: $(libs_shared) library-test.o + @echo " [LD] $@" + $(Q)$(CC) $(CFLAGS) -o library-test library-test.o $(LDFLAGS) -lbtrfs + +library-test.static: $(libs_static) library-test.o + @echo " [LD] $@" + $(Q)$(CC) $(CFLAGS) -o library-test-static library-test.o $(LDFLAGS) $(libs_static) + manpages: $(Q)$(MAKE) $(MAKEOPTS) -C Documentation diff --git a/library-test.c b/library-test.c new file mode 100644 index 000000000000..142188a73b45 --- /dev/null +++ b/library-test.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2014 SUSE. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License v2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include "kerncompat.h" +#include "version.h" +#include "send-stream.h" + +/* + * Reduced code snippet from snapper.git/snapper/Btrfs.cc + */ +struct btrfs_send_ops send_ops = { + .subvol = NULL, + .snapshot = NULL, + .mkfile = NULL, + .mkdir = NULL, + .mknod = NULL, + .mkfifo = NULL, + .mksock = NULL, + .symlink = NULL, + .rename = NULL, + .link = NULL, + .unlink = NULL, + .rmdir = NULL, + .write = NULL, + .clone = NULL, + .set_xattr = NULL, + .remove_xattr = NULL, + .truncate = NULL, + .chmod = NULL, + .chown = NULL, + .utimes = NULL, + .update_extent = NULL, +}; + +/* + * Link test only, not intended to be executed. + */ +static int test_send_stream_api() { + int ret; + int fd = -1; + +#if BTRFS_LIB_VERSION < 101 + ret = btrfs_read_and_process_send_stream(fd, &send_ops, NULL, 0); +#else + ret = btrfs_read_and_process_send_stream(fd, &send_ops, NULL, 0, 1); +#endif + return ret; +} + +int main() { + test_send_stream_api(); + + return 0; +}