Skip to content

Commit

Permalink
Improve testing for the C API
Browse files Browse the repository at this point in the history
Summary:
This basically add an echo test case in C. The support is limited right now, but full support would just be too much to review at once.

The echo test case simply get a module as input and try to output the same exact module. This allow to check the both reading and writing API are working as expected.

I want to improve this test over time to support more and more of the API, in order to improve coverage (coverage is quite poor right now).

Test Plan: Run the test.

Reviewers: chandlerc, bogner

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D10725

llvm-svn: 259844
  • Loading branch information
deadalnix committed Feb 4, 2016
1 parent f9cec37 commit e8ea7d8
Show file tree
Hide file tree
Showing 9 changed files with 520 additions and 6 deletions.
32 changes: 32 additions & 0 deletions llvm/test/Bindings/llvm-c/echo.ll
@@ -0,0 +1,32 @@
; RUN: llvm-as < %s | llvm-dis > %t.orig
; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
; RUN: diff %t.orig %t.echo

declare void @decl()

; TODO: label, struct and metadata types
define void @types() {
%1 = alloca half
%2 = alloca float
%3 = alloca double
%4 = alloca x86_fp80
%5 = alloca fp128
%6 = alloca ppc_fp128
%7 = alloca i7
%8 = alloca void (i1)*
%9 = alloca [3 x i22]
%10 = alloca i328 addrspace(5)*
%11 = alloca <5 x i23*>
%12 = alloca x86_mmx
ret void
}

define i32 @add(i32 %a, i32 %b) {
%1 = add i32 %a, %b
ret i32 %1
}

define i32 @call() {
%1 = call i32 @add(i32 23, i32 19)
ret i32 %1
}
1 change: 1 addition & 0 deletions llvm/tools/llvm-c-test/CMakeLists.txt
Expand Up @@ -37,6 +37,7 @@ endif ()
add_llvm_tool(llvm-c-test
calc.c
disassemble.c
echo.cpp
helpers.c
include-all.c
main.c
Expand Down
1 change: 0 additions & 1 deletion llvm/tools/llvm-c-test/calc.c
Expand Up @@ -14,7 +14,6 @@
\*===----------------------------------------------------------------------===*/

#include "llvm-c-test.h"
#include "llvm-c/Core.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down

0 comments on commit e8ea7d8

Please sign in to comment.