blob: 539defd625382bbce14ded35030b71189efa6801 [file] [log] [blame] [raw]
Matt Godboltca017ba2021-08-14 12:53:22 -05001// Copyright (c) 2021, Compiler Explorer Authors
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are met:
6//
7// * Redistributions of source code must retain the above copyright notice,
8// this list of conditions and the following disclaimer.
9// * Redistributions in binary form must reproduce the above copyright
10// notice, this list of conditions and the following disclaimer in the
11// documentation and/or other materials provided with the distribution.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23// POSSIBILITY OF SUCH DAMAGE.
24
Matt Godboltf2c1e0b2022-05-09 23:13:50 -050025import {ClangCompiler} from '../../lib/compilers';
26import {chai, makeCompilationEnvironment} from '../utils';
Matt Godboltca017ba2021-08-14 12:53:22 -050027
28const expect = chai.expect;
29
30describe('clang tests', () => {
31 const languages = {'c++': {id: 'c++'}};
32
33 const info = {
34 exe: null,
35 remote: true,
36 lang: 'c++',
37 ldPath: [],
38 };
39
40 describe('device code...', async () => {
41 const clang = new ClangCompiler(info, makeCompilationEnvironment({languages}));
42 it('Should return null for non-device code', () => {
43 expect(clang.splitDeviceCode('')).to.be.null;
44 expect(clang.splitDeviceCode('mov eax, 00h\nadd r0, r0, #1\n')).to.be.null;
45 });
46 it('should separate out bundles ', () => {
Matt Godboltf2c1e0b2022-05-09 23:13:50 -050047 expect(
48 clang.splitDeviceCode(`# __CLANG_OFFLOAD_BUNDLE____START__ openmp-x86_64-unknown-linux-gnu
Matt Godboltca017ba2021-08-14 12:53:22 -050049 i am some
50 linux remote stuff
51# __CLANG_OFFLOAD_BUNDLE____END__ openmp-x86_64-unknown-linux-gnu
52
53# __CLANG_OFFLOAD_BUNDLE____START__ host-x86_64-unknown-linux-gnu
54 whereas
55 i am host code
56# __CLANG_OFFLOAD_BUNDLE____END__ host-x86_64-unknown-linux-gnu
Matt Godboltf2c1e0b2022-05-09 23:13:50 -050057`),
58 ).to.deep.equal({
Matt Godboltca017ba2021-08-14 12:53:22 -050059 'host-x86_64-unknown-linux-gnu': ' whereas\n i am host code\n',
60 'openmp-x86_64-unknown-linux-gnu': ' i am some\n linux remote stuff\n',
61 });
62 });
63 });
64});